From 8638004215f29625847ea345f1cfadb446417c1f Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Sun, 30 Jun 2019 15:17:25 +0200 Subject: [PATCH] More helpful error message if no component is selected in LogicUICanvas --- .../src/net/mograsim/logic/ui/LogicUICanvas.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java index 8e01a162..73c1f06b 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java @@ -113,9 +113,10 @@ public class LogicUICanvas extends ZoomableCanvas { try { - if (componentSelector.getSelectionIndex() >= componentsByItemIndex.size()) - throw new RuntimeException("No valid component selected"); - GUIComponent target = componentsByItemIndex.get(componentSelector.getSelectionIndex()); + int componentIndex = componentSelector.getSelectionIndex(); + if (componentIndex < 0 || componentIndex >= componentsByItemIndex.size()) + throw new RuntimeException("No component selected"); + GUIComponent target = componentsByItemIndex.get(componentIndex); String valueString = valueText.getText(); Object value; if (radioBit.getSelection()) -- 2.17.1