diff options
author | Andrey Loskutov | 2018-09-14 08:44:26 +0000 |
---|---|---|
committer | Andrey Loskutov | 2018-09-14 08:44:26 +0000 |
commit | e0e894eacc962283a1dc81ab07ba56b330bd140e (patch) | |
tree | d268bf1f3721756032291ea513c79fb4c51343cb | |
parent | c6321fe6458dcbdd0d92915dbe14a72ed0cac34e (diff) | |
download | eclipse.platform-e0e894eacc962283a1dc81ab07ba56b330bd140e.tar.gz eclipse.platform-e0e894eacc962283a1dc81ab07ba56b330bd140e.tar.xz eclipse.platform-e0e894eacc962283a1dc81ab07ba56b330bd140e.zip |
Bug 355011 - prevent Color leaks via parallel creation
The missing colors could be created by multiple threads, but only one
instance will be later disposed, leading to possible SWT leaks.
Change-Id: I86f296f80c17a5d630a6fc7770883ef0ff95297b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r-- | ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ColorManager.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ColorManager.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ColorManager.java index 9742699d4..7e906473a 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ColorManager.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ColorManager.java @@ -45,8 +45,13 @@ public class ColorManager implements ISharedTextColors { public Color getColor(RGB rgb) { Color color = fColorTable.get(rgb); if (color == null) { - PlatformUI.getWorkbench().getDisplay().syncExec(() -> fColorTable.put(rgb, new Color(Display.getCurrent(), rgb))); - color = fColorTable.get(rgb); + synchronized (fColorTable) { + color = fColorTable.get(rgb); + if (color == null) { + PlatformUI.getWorkbench().getDisplay().syncExec(() -> fColorTable.put(rgb, new Color(Display.getCurrent(), rgb))); + color = fColorTable.get(rgb); + } + } } return color; } |