Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328699 - Exception was thrown when creating a ImageRegistry
Summary: Exception was thrown when creating a ImageRegistry
Status: RESOLVED NOT_ECLIPSE
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-26 09:05 EDT by Samuel Wu CLA
Modified: 2010-10-28 10:01 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Wu CLA 2010-10-26 09:05:59 EDT
Build Identifier: Eclipse 3.6.1

The following NPE was thrown during debug. The problem can't be reproduced at will. It looks that Display.getCurrent() returns null.

java.lang.NullPointerException
at org.eclipse.jface.resource.JFaceResources.getResources(JFaceResources.java:207)
at org.eclipse.jface.resource.ImageRegistry.<init>(ImageRegistry.java:152)
at org.eclipse.jface.resource.ImageRegistry.<init>(ImageRegistry.java:124)
at com.ibm.debug.pdt.internal.common.CommonUtils.initializeImageRegistry(CommonUtils.java:149)
at com.ibm.debug.pdt.internal.common.CommonUtils.getImage(CommonUtils.java:181)
at com.ibm.debug.pdt.common.DebugImageDescriptor.addOverlays(DebugImageDescriptor.java:81)
at com.ibm.debug.pdt.common.DebugImageDescriptor.drawCompositeImage(DebugImageDescriptor.java:59)
at org.eclipse.jface.resource.CompositeImageDescriptor.getImageData(CompositeImageDescriptor.java:154)
at org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:273)
at org.eclipse.jface.resource.ImageDescriptor.createResource(ImageDescriptor.java:165)
at org.eclipse.jface.resource.DeviceResourceManager.allocate(DeviceResourceManager.java:56)
at org.eclipse.jface.resource.AbstractResourceManager.create(AbstractResourceManager.java:88)
at org.eclipse.jface.resource.ResourceManager.createImageWithDefault(ResourceManager.java:192)
at org.eclipse.jface.resource.ImageRegistry.get(ImageRegistry.java:212)
at com.ibm.debug.pdt.internal.ui.PICLUtils.getImage(PICLUtils.java:374)
at com.ibm.debug.pdt.internal.ui.PDTModelPresentation.getImage(PDTModelPresentation.java:198)
at org.eclipse.debug.internal.ui.LazyModelPresentation.getImage(LazyModelPresentation.java:127)
at org.eclipse.debug.internal.ui.DelegatingModelPresentation.getImage(DelegatingModelPresentation.java:143)
at org.eclipse.debug.internal.ui.views.launch.DebugElementHelper.getImageDescriptor(DebugElementHelper.java:70)
at org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider.getImageDescriptor(DebugElementLabelProvider.java:72)
at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider.getImageDescriptor(ElementLabelProvider.java:289)
at org.eclipse.debug.internal.ui.model.elements.BreakpointLabelProvider.getImageDescriptor(BreakpointLabelProvider.java:43)
at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider.retrieveLabel(ElementLabelProvider.java:216)
at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider$LabelUpdater.run(ElementLabelProvider.java:160)
at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider$LabelJob.run(ElementLabelProvider.java:74)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Reproducible: Couldn't Reproduce
Comment 1 Remy Suen CLA 2010-10-26 09:18:38 EDT
(In reply to comment #0)
> The following NPE was thrown during debug. The problem can't be reproduced at
> will. It looks that Display.getCurrent() returns null.

Since the trace shows that the code is being run from a job, having the current display be 'null' is not surprising. I would suggest trying to get the display from the workbench instead (PlatformUI.getWorkbench().getDisplay()) instead of using the no-argument ImageRegistry constructor.

Debug, do you agree?
Comment 2 Darin Wright CLA 2010-10-27 11:04:59 EDT
Note that if your debug mode presentation requires the UI thread for generating labels/images then it should implement org.eclipse.debug.ui.IDebugModelPresentationExtension. Otherwise a non-UI thread is used to generate labels.

For example, the JDT model presentation builds a cache of images, and requires the UI thread until the cache is initialized.
Comment 3 Sean Kennedy CLA 2010-10-28 09:58:29 EDT
The normal way to run this is with an asyncExec() on the display to init the image registry.
Looks like there might be race that this causing the trouble.

Likely not an Eclipse issue.
Comment 4 Darin Wright CLA 2010-10-28 10:01:12 EDT
Looks like an issue with com.ibm.debug.pdt. Closing as Not Eclipse.