Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJonah Graham2020-05-22 04:22:07 +0000
committerJonah Graham2020-05-31 21:30:21 +0000
commit125afa92dcd51dc42e718a4ec011d6e1d441ca76 (patch)
tree8318ae35f8f7292430f3b924cafcaf717056f880 /core
parentd70af1889702ce8621d5c8dc135fe7a3c666f20b (diff)
downloadorg.eclipse.cdt-125afa92dcd51dc42e718a4ec011d6e1d441ca76.tar.gz
org.eclipse.cdt-125afa92dcd51dc42e718a4ec011d6e1d441ca76.tar.xz
org.eclipse.cdt-125afa92dcd51dc42e718a4ec011d6e1d441ca76.zip
Bug 563455: Always return same instance of CElementImageDescriptor to platform
Because of a bug in the platform implementation of equals/hashCode under some circumstances, we can workaround the problem by returning the same instance of CElementImageDescriptor when the objects are equal(). Change-Id: I6ff15cffa4b48080dcc6c9a023622edf4ae2d497
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java
index fcafb95ebf7..bc4bbcabd1e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java
@@ -16,6 +16,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
@@ -114,6 +117,12 @@ public class CElementImageProvider {
//DESC_OBJ_FOLDER= images.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
}
+ /**
+ * Map of a descriptor back to its canonical one. This is needed to work around a bug in
+ * the Eclipse platform, see Bug 563454
+ */
+ private final Map<CElementImageDescriptor, CElementImageDescriptor> allDescriptors = new HashMap<>();
+
public CElementImageProvider() {
}
@@ -300,7 +309,9 @@ public class CElementImageProvider {
Point size = useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
ImageDescriptor desc = getBaseImageDescriptor(element, flags);
if (desc != null) {
- return new CElementImageDescriptor(desc, adornmentFlags, size);
+ CElementImageDescriptor descriptor = new CElementImageDescriptor(desc, adornmentFlags, size);
+ descriptor = allDescriptors.computeIfAbsent(descriptor, (k) -> k);
+ return descriptor;
}
return null;
}

Back to the top