executeWithDifferentColor no longer crashes if col==null
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Tue, 25 Jun 2019 08:49:19 +0000 (10:49 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Tue, 25 Jun 2019 08:49:19 +0000 (10:49 +0200)
net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java
net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java

index 0ec42f5..0b65d2b 100644 (file)
@@ -23,12 +23,17 @@ public class ColorHelper
 
        private static void executeWithDifferentColor(ColorDefinition col, Supplier<Color> getColor, Consumer<Color> setColor, Runnable exec)
        {
-               ColorManager cm = ColorManager.current();
-               Color oldColor = getColor.get();
-               Color newColor = cm.toColor(col);
-               setColor.accept(newColor);
-               exec.run();
-               setColor.accept(oldColor);
+               if (col == null)
+                       exec.run();
+               else
+               {
+                       ColorManager cm = ColorManager.current();
+                       Color oldColor = getColor.get();
+                       Color newColor = cm.toColor(col);
+                       setColor.accept(newColor);
+                       exec.run();
+                       setColor.accept(oldColor);
+               }
        }
 
        private ColorHelper()
index 61e0b38..31713ea 100644 (file)
@@ -28,7 +28,6 @@ import net.mograsim.logic.ui.model.wires.GUIWire;
 import net.mograsim.logic.ui.modeladapter.LogicModelParameters;
 import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.preferences.ColorDefinition;
-import net.mograsim.preferences.ColorDefinition.BuiltInColor;
 import net.mograsim.preferences.Preferences;
 
 public class LogicUIPart extends ViewPart
@@ -59,7 +58,7 @@ public class LogicUIPart extends ViewPart
                                if (rgb == null)
                                {
                                        StatusManager.getManager().handle(new Status(IStatus.ERROR, "net.mograsim.plugin.core", "No color for name " + name));
-                                       return new ColorDefinition(BuiltInColor.COLOR_BLACK);
+                                       return null;
                                }
                                return new ColorDefinition(rgb.red, rgb.green, rgb.blue);
                        }