This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 433707 - Switching themes creates Graphic is disposed error
Summary: Switching themes creates Graphic is disposed error
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 4.4 RC1   Edit
Assignee: Daniel Rolka CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-28 15:29 EDT by Lars Vogel CLA
Modified: 2014-05-13 05:05 EDT (History)
2 users (show)

See Also:


Attachments
Test case with a labeled screenshot (5.57 KB, image/png)
2014-04-29 05:55 EDT, Lars Vogel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2014-04-28 15:29:37 EDT
If I start our org.eclipse.e4.demo.contacts RCP application and switch between the themes I get the following exception from below.


org.eclipse.swt.SWTException: Graphic is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4441)
	at org.eclipse.swt.SWT.error(SWT.java:4356)
	at org.eclipse.swt.SWT.error(SWT.java:4327)
	at org.eclipse.swt.graphics.Color.getRGB(Color.java:217)
	at org.eclipse.swt.custom.CTabFolderRenderer.createAntialiasColors(CTabFolderRenderer.java:455)
	at org.eclipse.swt.custom.CTabFolder.setBackground(CTabFolder.java:2268)
	at org.eclipse.swt.custom.CTabFolder.setBackground(CTabFolder.java:2377)
	at org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyUnselectedTabsSWTHandler.applyCSSProperty(CSSPropertyUnselectedTabsSWTHandler.java:65)
	at org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler.applyCSSProperty(AbstractCSSPropertySWTHandler.java:40)
	at org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.applyCSSProperty(AbstractCSSEngine.java:722)
	at org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.applyStyleDeclaration(AbstractCSSEngine.java:520)
	at org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.applyStyles(AbstractCSSEngine.java:405)
	at org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.applyStyles(AbstractCSSEngine.java:354)
	at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.applyStyles(ThemeEngine.java:514)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$11.setClassnameAndId(PartRenderingEngine.java:1322)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.setCSSInfo(SWTPartRenderer.java:110)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.styleElement(SWTPartRenderer.java:80)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer$5.handleEvent(StackRenderer.java:524)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:187)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4598)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:207)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:36)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:81)
	at org.eclipse.e4.ui.workbench.UIEvents.publishEvent(UIEvents.java:364)
	at org.eclipse.e4.ui.workbench.UIEvents.publishEvent(UIEvents.java:333)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:650)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:613)
	at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:106)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer$9.handleEvent(StackRenderer.java:1016)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4462)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1412)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1397)
	at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1714)
	at org.eclipse.swt.widgets.Control.gtk_button_press_event(Control.java:3024)
	at org.eclipse.swt.widgets.Control.gtk_button_press_event(Control.java:2960)
	at org.eclipse.swt.widgets.Composite.gtk_button_press_event(Composite.java:723)
	at org.eclipse.swt.widgets.Table.gtk_button_press_event(Table.java:1834)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2077)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5506)
	at org.eclipse.swt.widgets.Table.windowProc(Table.java:3672)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4676)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9074)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1253)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2473)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3414)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1152)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1033)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:162)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:233)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 1 Lars Vogel CLA 2014-04-28 15:31:29 EDT
Daniel, is this a bug in the dark theme or in the CSS engine?
Comment 2 Daniel Rolka CLA 2014-04-29 05:07:12 EDT
(In reply to Lars Vogel from comment #1)
> Daniel, is this a bug in the dark theme or in the CSS engine?

Have you seen the issue switching between the 'e4 default' themes? If not, it seems to be the Dark theme one. 

Maybe we should add some additional check for the 'resource disposed' state in the CSSPropertyUnselectedTabsSWTHandler handler

Daniel
Comment 3 Lars Vogel CLA 2014-04-29 05:55:19 EDT
(In reply to Daniel Rolka from comment #2)
> (In reply to Lars Vogel from comment #1)
> > Daniel, is this a bug in the dark theme or in the CSS engine?
> 
> Have you seen the issue switching between the 'e4 default' themes? If not,
> it seems to be the Dark theme one. 
> 
> Maybe we should add some additional check for the 'resource disposed' state
> in the CSSPropertyUnselectedTabsSWTHandler handler

The first time every theme works fine. To test start the app and select the buttons in the displayed order of the screenshot -> all good, which implies to me that the themes are OK.

Only afterwards switching the theme creates the exception.
Comment 4 Lars Vogel CLA 2014-04-29 05:55:56 EDT
Created attachment 242460 [details]
Test case with a labeled screenshot
Comment 5 Daniel Rolka CLA 2014-04-29 07:50:06 EDT
It works fine for me - build I20140428-2000, Windows 7

Do I have to do anything else except of switching the themes in the 'Test case with a labeled screenshot' order?

Anyway the 'Graphic is disposed' exception during switching the theme means that we skip sth during reseting the previous theme and it is still in use after applying the new theme (the new theme doesn't override it)

Daniel
Comment 6 Lars Vogel CLA 2014-04-29 08:03:49 EDT
(In reply to Daniel Rolka from comment #5)
> It works fine for me - build I20140428-2000, Windows 7
> 
> Do I have to do anything else except of switching the themes in the 'Test
> case with a labeled screenshot' order?

Not sure what you mean. The example is our org.eclipse.e4.demo.contacts demo from the eclipse.platform.ui repo. Select the contacts.product file and start it from there. Afterwards switch the themes as highlighted in the screenshot. Sorry, if that was unclear, I use "contacts" that long, that I tend to assume that everyone knows that. If that was not your question, can you please clarify?

> Anyway the 'Graphic is disposed' exception during switching the theme means
> that we skip sth during reseting the previous theme and it is still in use
> after applying the new theme (the new theme doesn't override it)
> 
> Daniel
Comment 7 Daniel Rolka CLA 2014-04-29 08:14:11 EDT
(In reply to Lars Vogel from comment #6)
> Not sure what you mean. The example is our org.eclipse.e4.demo.contacts demo
> from the eclipse.platform.ui repo. Select the contacts.product file and
> start it from there. Afterwards switch the themes as highlighted in the
> screenshot. Sorry, if that was unclear, I use "contacts" that long, that I
> tend to assume that everyone knows that. If that was not your question, can
> you please clarify?

I did exactly as you wrote, but I don't get the exception when I switch the theme buttons in the 1,2,3 order (as the snapshot presents)

My question was about some other steps that could be omitted in order to recreate the issue

Daniel
Comment 8 Lars Vogel CLA 2014-04-29 08:23:46 EDT
(In reply to Daniel Rolka from comment #7)
> (In reply to Lars Vogel from comment #6)
> > Not sure what you mean. The example is our org.eclipse.e4.demo.contacts demo
> > from the eclipse.platform.ui repo. Select the contacts.product file and
> > start it from there. Afterwards switch the themes as highlighted in the
> > screenshot. Sorry, if that was unclear, I use "contacts" that long, that I
> > tend to assume that everyone knows that. If that was not your question, can
> > you please clarify?
> 
> I did exactly as you wrote, but I don't get the exception when I switch the
> theme buttons in the 1,2,3 order (as the snapshot presents)

After 3 you have to press 1 or 2 again. This triggers the exception.
Comment 9 Daniel Rolka CLA 2014-04-29 08:42:08 EDT
(In reply to Lars Vogel from comment #8)
> (In reply to Daniel Rolka from comment #7)
> > (In reply to Lars Vogel from comment #6)
> > > Not sure what you mean. The example is our org.eclipse.e4.demo.contacts demo
> > > from the eclipse.platform.ui repo. Select the contacts.product file and
> > > start it from there. Afterwards switch the themes as highlighted in the
> > > screenshot. Sorry, if that was unclear, I use "contacts" that long, that I
> > > tend to assume that everyone knows that. If that was not your question, can
> > > you please clarify?
> > 
> > I did exactly as you wrote, but I don't get the exception when I switch the
> > theme buttons in the 1,2,3 order (as the snapshot presents)
> 
> After 3 you have to press 1 or 2 again. This triggers the exception.

And nothing, it still works fine in my local env with the I20140428-2000 build

Let's return to it after the Test day

Daniel
Comment 10 Daniel Rolka CLA 2014-05-13 05:05:31 EDT
It works fine for me. Please reopen the bug when the issue occurs again

Daniel