From 1837ad8fb133d0e27841d8a07a3f62c1704ded63 Mon Sep 17 00:00:00 2001 From: Joe Ross Date: Sun, 30 Nov 2014 17:31:21 -0800 Subject: Fix crash in SendableChooser ComboBox with no NT con. Fixes artf3857. Check for NT null in ComboBox. Copied code from RadioButtons. RadioButtons does not used syncronized(table), so it is assumed that it is safe to remove. Change-Id: I7c06bd30f05b279ddc52309f1560b8ef46a3a4c4 --- .../first/smartdashboard/gui/elements/Chooser.java | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/Chooser.java b/smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/Chooser.java index ac098cb..5072461 100644 --- a/smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/Chooser.java +++ b/smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/Chooser.java @@ -237,38 +237,35 @@ public class Chooser extends AbstractTableWidget implements ITableListener combo = new JComboBox(); - synchronized (table) - { - boolean hasSelection = false; + boolean hasSelection = false; - for (int i = 0; i < choices.size(); i++) - { + for (int i = 0; i < choices.size(); i++) + { String choice = choices.get(i); hasSelection |= choice.equals(selection); combo.addItem(choice); - } + } - if (!hasSelection) - { + if (!hasSelection) + { selection = null; - } + } - if (table.containsKey(SELECTED)) - { + if (table != null && table.containsKey(SELECTED)) + { selection = table.getString(SELECTED); - } + } - if (selection != null) - { + if (table != null && selection != null) + { combo.setSelectedItem(selection); table.putString(SELECTED, selection); - } else - { - if (table.containsKey(DEFAULT)) + } else + { + if (table != null && table.containsKey(DEFAULT)) { - combo.setSelectedItem(table.getString(DEFAULT)); + combo.setSelectedItem(table.getString(DEFAULT)); } - } } panel.add(combo); -- cgit v1.2.3-54-g00ecf