mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
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
This commit is contained in:
parent
d70af18897
commit
125afa92dc
1 changed files with 12 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue