Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » "Graphic is Disposed" Exception
"Graphic is Disposed" Exception [message #345042] Tue, 28 July 2009 06:56 Go to next message
Marc Mising name is currently offline Marc Mising nameFriend
Messages: 193
Registered: July 2009
Location: Valencia, Spain
Senior Member
Hi, I have an editor where I can draw nodes with one label, having an icon
and the text. This node can have a diagram, which it's of the same kind as
its parent. When I open this second digram and I have the parent opened
too, sometimes I get a "Graphic is Disposed" Exception in the first
diagram: if I go to the first diagram, the figure label disappears.

Debugging I found that Eclipse tries to refresh the editParts of the
diagram, and try to refresh the label and the icon (a WrappingLabel):

WrappingLabel line #1132
------------------------
private void paintIcons(Graphics graphics) {
Point p = Point.SINGLETON;

if (getIconLocation() != null) {
p.setLocation(getIconLocation());

Rectangle figBounds = getBounds();
graphics.translate(figBounds.x, figBounds.y);

int num = getNumberofIcons();
for (int i = 0; i < num; i++) {
Image icon = getIcon(i);
if (icon != null) {
graphics.drawImage(icon, p); // <-- Here fails
p.x += getIconSize(i).width;
}
}
graphics.translate(-figBounds.x, -figBounds.y);
}
}

Eclipse checks if the Image (the icon) is disposed, and shows the
exception. But why the icon is disposed? How can I force to create the
icon another time?

I try in the XXX.part.XElementTypes class, in the getImageDescriptor() and
getImage() funtions, forcing to create always the images, but doesn't work.

Any suggestions?

Thanks a lot!!
Marc
Re: "Graphic is Disposed" Exception [message #353848 is a reply to message #345042] Tue, 28 July 2009 10:51 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Marc,

> parent opened too, sometimes I get a "Graphic is Disposed" Exception
Can you post a full stacktrace of this exception here?

-----------------
Alex Shatalin
Re: "Graphic is Disposed" Exception [message #358137 is a reply to message #353848] Tue, 28 July 2009 12:44 Go to previous message
Marc Mising name is currently offline Marc Mising nameFriend
Messages: 193
Registered: July 2009
Location: Valencia, Spain
Senior Member
Alex Shatalin wrote:

> Hello Marc,

>> parent opened too, sometimes I get a "Graphic is Disposed" Exception
> Can you post a full stacktrace of this exception here?

> -----------------
> Alex Shatalin

Hello Alex, I have resolved it refreshing all the icons in the diagram
everytime the diagram is shown. I post the stacktrace, but debugging I
know that internally it was doing a diagram refresh that force to repaint
the icons, and if they are disposed, crashes. Who dispose this icons is
something I don't know. We're using MultiTab diagrams... Perhaps it's our
problem... But we've solved it ;)

Thanks Alex.

org.eclipse.swt.SWTException: Graphic is disposed
at org.eclipse.swt.SWT.error(SWT.java:3777)
at org.eclipse.swt.SWT.error(SWT.java:3695)
at org.eclipse.swt.SWT.error(SWT.java:3666)
at org.eclipse.swt.graphics.Image.getBounds(Image.java:1148)
at
org.eclipse.gmf.runtime.draw2d.ui.internal.graphics.MapModeG raphics.drawImage(MapModeGraphics.java:53)
at org.eclipse.draw2d.Graphics.drawImage(Graphics.java:148)
at
org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel.pain tIcons(WrappingLabel.java:1145)
at
org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel.pain tFigure(WrappingLabel.java:1091)
at org.eclipse.draw2d.Figure.paint(Figure.java:1049)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1123)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at
org.eclipse.draw2d.ScalableFreeformLayeredPane.paintClientAr ea(ScalableFreeformLayeredPane.java:61)
at
org.eclipse.gmf.runtime.draw2d.ui.internal.graphics.Scalable FreeformLayeredPane.paintClientArea(ScalableFreeformLayeredP ane.java:82)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1114)
at org.eclipse.draw2d.Viewport.paintClientArea(Viewport.java:15 6)
at
es.cv.gvcase.mdt.bpmn.figures.splitviewsupport.FreeFormViewP ortWithSplitters.paintClientArea(FreeFormViewPortWithSplitte rs.java:54)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1087)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1119)
at org.eclipse.draw2d.Figure.paint(Figure.java:1051)
at
org.eclipse.draw2d.DeferredUpdateManager.paint(DeferredUpdat eManager.java:155)
at org.eclipse.draw2d.LightweightSystem.paint(LightweightSystem .java:199)
at
org.eclipse.draw2d.LightweightSystem$2.handleEvent(Lightweig htSystem.java:107)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:14 24)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3842 )
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4541 )
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:23 70)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3420)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Previous Topic:Parameterized Actions?
Next Topic:WrappingLable cannot display Chinese
Goto Forum:
  


Current Time: Tue Mar 19 10:05:49 GMT 2024

Powered by FUDForum. Page generated in 0.01840 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top