Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error: SWT Resource was not properly disposed" in ScaledGraphics.zoomTextLayout() #436

Closed
cedric780 opened this issue May 2, 2024 · 0 comments · Fixed by #437
Closed

Comments

@cedric780
Copy link
Contributor

Latest Eclipse RCP introduced a watchdog that reports all no disposed SWT resource that get garbage collected.
Since them I get a lot of traces in the console with this stack trace:

java.lang.Error: SWT Resource was not properly disposed
	at org.eclipse.swt.graphics.Resource.initNonDisposeTracking(Resource.java:172)
	at org.eclipse.swt.graphics.Resource.<init>(Resource.java:120)
	at org.eclipse.swt.graphics.TextLayout.<init>(TextLayout.java:299)
	at org.eclipse.draw2d.ScaledGraphics.zoomTextLayout(ScaledGraphics.java:980)
	at org.eclipse.draw2d.ScaledGraphics.drawTextLayout(ScaledGraphics.java:414)
	at org.eclipse.draw2d.Graphics.drawTextLayout(Graphics.java:457)
	...

I use draw2d 3.10.xxx but it seems the bug is still present in latest version, I think the problem originates here:

The zoomed TextLayout should be disposed when returning null.

@cedric780 cedric780 changed the title "Error: SWT Resource was not properly disposed" in ScaledGraphics.zoomTextLayout(ScaledGraphics.java:980) "Error: SWT Resource was not properly disposed" in ScaledGraphics.zoomTextLayout() May 2, 2024
cedric780 added a commit to cedric780/gef-classic that referenced this issue May 2, 2024
…ScaledGraphics.zoomTextLayout()

[eclipse#436] Fix "Error: SWT Resource was not properly disposed" in ScaledGraphics.zoomTextLayout()

Resolves eclipse#436
Dispose the TextLayout when returning null.

Signed-off-by: Cedric Marin <cedric.dev.780@gmail.com>
ptziegler pushed a commit that referenced this issue May 3, 2024
#437)

* Fix [#436] "Error: SWT Resource was not properly disposed" in ScaledGraphics.zoomTextLayout()

[#436] Fix "Error: SWT Resource was not properly disposed" in ScaledGraphics.zoomTextLayout()

Resolves #436
Dispose the TextLayout when returning null.

Signed-off-by: Cedric Marin <cedric.dev.780@gmail.com>

* Apply ptziegleril suggestion:
> Instead of creating and disposing the resources, wouldn't it make more sense to move it so that it's only created after this check?

---------

Signed-off-by: Cedric Marin <cedric.dev.780@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant