From: Daniel Kirschten Date: Tue, 25 Jun 2019 08:49:19 +0000 (+0200) Subject: executeWithDifferentColor no longer crashes if col==null X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=3980458ffcd8da081aa7ce6b6bdb34ee8d8980ac;p=Mograsim.git executeWithDifferentColor no longer crashes if col==null --- diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java index 0ec42f57..0b65d2be 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java @@ -23,12 +23,17 @@ public class ColorHelper private static void executeWithDifferentColor(ColorDefinition col, Supplier getColor, Consumer 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() diff --git a/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java b/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java index 61e0b384..31713ea3 100644 --- a/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java @@ -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); }