Community
Participate
Working Groups
The test code to reproduce this problem is very simple: Display display = Display.getDefault(); Shell root = new Shell(display, SWT.SHELL_TRIM); Shell child = new Shell(root, SWT.SHELL_TRIM); child.addListener(SWT.Dispose, e -> root.dispose()); root.dispose(); This results in the following NPE on Cocoa, but not win32 or gtk. This bug is present in Oxygen, and also previous versions, I believe. java.lang.NullPointerException at org.eclipse.swt.widgets.Composite._getChildren(Composite.java:95) at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:957) at org.eclipse.swt.widgets.Canvas.releaseChildren(Canvas.java:348) at org.eclipse.swt.widgets.Decorations.releaseChildren(Decorations.java:403) at org.eclipse.swt.widgets.Shell.releaseChildren(Shell.java:1417) at org.eclipse.swt.widgets.Widget.release(Widget.java:1345) at org.eclipse.swt.widgets.Control.release(Control.java:2943) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:686) at (the root.dispose() line) Currently, Widget.release looks like this: void release (boolean destroy) { if ((state & DISPOSE_SENT) == 0) { state |= DISPOSE_SENT; sendEvent (SWT.Dispose); } if ((state & DISPOSED) == 0) { releaseChildren (destroy); } ... One possible fix, to ensure that releaseChildren is only called once, is this: void release (boolean destroy) { if ((state & DISPOSE_SENT) == 0) { state |= DISPOSE_SENT; sendEvent (SWT.Dispose); releaseChildren (destroy); } ... But this is old deep code, so maybe I'm missing a bigger picture.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Retested with `4.13.0` aka `2019-09` aka `3.112.0`. Same problem persists. Here are the new line numbers: java.lang.NullPointerException at org.eclipse.swt.widgets.Composite._getChildren(Composite.java:99) at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:953) at org.eclipse.swt.widgets.Canvas.releaseChildren(Canvas.java:352) at org.eclipse.swt.widgets.Decorations.releaseChildren(Decorations.java:406) at org.eclipse.swt.widgets.Shell.releaseChildren(Shell.java:1420) at org.eclipse.swt.widgets.Widget.release(Widget.java:1356) at org.eclipse.swt.widgets.Control.release(Control.java:2974) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:694)
Thanks for confirming that this bug is still valid. Maybe you could provide a Gerrit patch? This would also run all UI tests. I would assume that if this would introduce a regression that at least one UI test should fail. Even better, could you add a dedicated unit test? Then we need an SWT expert to review this. (I'm not one ;-) )
If I could submit a PR on GitHub it would already be submitted. As it is, the bug is pretty easy to workaround, and it's easier for me to keep our workaround in place than to navigate bugzilla and gerrit. I've submitted patches before, but I feel that I spend more time futzing with the tools than the actual thing I'm attempting to contribute. Would be awesome if there was a workflow for allowing GitHub issues and contributions. Similar to git-svn, doesn't need to be a project switch, just a parallel universe where everything gets merged together eventually. I realize that's out-of-scope here, just want to be honest and realistic about how I spend my time contributing upstream to open source projects.
I don't have a MAC setup, but going by the code I attempted a possible work-around for this NPE, will share a gerrit.
New Gerrit change created: https://git.eclipse.org/r/150599
Thanks Karsten for the updated patch, we will look into this post M1.
Gerrit change https://git.eclipse.org/r/150599 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=53d450854a768db924003aaead9d7df6e96f7fe8
(In reply to Eclipse Genie from comment #8) > Gerrit change https://git.eclipse.org/r/150599 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=53d450854a768db924003aaead9d7df6e96f7fe8 Thanks Sravan for the review, resolving now.
Verified on I20191119-1250 with JUnit test.
*** Bug 466766 has been marked as a duplicate of this bug. ***