summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Ross <git@rossesmail.com>2014-11-30 17:31:21 -0800
committerJoe Ross <git@rossesmail.com>2014-12-01 21:04:02 -0800
commit1837ad8fb133d0e27841d8a07a3f62c1704ded63 (patch)
tree4cb58876f6b6b32fee7a18ab84bdfb4a7bc7fdb3
parentba05df10445684b21231fd31e0364198af4e5100 (diff)
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
-rw-r--r--smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/Chooser.java35
1 files 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);