Community
Participate
Working Groups
Build Identifier: 20090920-1017 WizardPageSupport/DialogPageSupport attempts to dispose of ValidationStatusProvider and causes NPE. I have a wizard where each page has its own DataBindingContext and i then use WizardPageSupport to provider the bindings/validation. The dispose() method of each wizard page calls dispose() on each of the databinding context. If a page contains a ValidationStatusProvider and the page is closed the WizardPageSupport attempts to remove the ValidationStatusProvider which has already been disposed of by the databinding context's disposal. As a result a NPE occurs. I'm unsure which should be responsible for disposing of everything. java.lang.NullPointerException at org.eclipse.jface.databinding.dialog.DialogPageSupport.dispose(DialogPageSupport.java:322) at org.eclipse.jface.databinding.dialog.DialogPageSupport$6.handleEvent(DialogPageSupport.java:166) 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:1008) at org.eclipse.swt.widgets.Widget.release(Widget.java:804) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:441) at org.eclipse.swt.widgets.Decorations.dispose(Decorations.java:447) at org.eclipse.swt.widgets.Shell.dispose(Shell.java:709) at org.eclipse.jface.window.Window.close(Window.java:335) at org.eclipse.jface.dialogs.Dialog.close(Dialog.java:979) at org.eclipse.jface.dialogs.TrayDialog.close(TrayDialog.java:179) at org.eclipse.jface.wizard.WizardDialog.hardClose(WizardDialog.java:807) at org.eclipse.jface.wizard.WizardDialog.close(WizardDialog.java:427) at org.eclipse.jface.wizard.WizardDialog.cancelPressed(WizardDialog.java:414) at org.eclipse.jface.wizard.WizardDialog$1.widgetSelected(WizardDialog.java:293) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228) 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.Display.runDeferredEvents(Display.java:3880) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473) at org.eclipse.jface.window.Window.runEventLoop(Window.java:825) at org.eclipse.jface.window.Window.open(Window.java:801) ..... Reproducible: Always
Additional info: This only appears to occur when the wizard is cancelled.
Created attachment 170094 [details] patch fixing the NPE with tests Matt, the NPE is occuring only when the wizard is canceled since otherwise the uiChanged flag of the DialogPageSupport class is likely to be true in which case the code triggering the NPE is not executed. Could you maybe check whether this patch solves the problem?
Ovidio, Thanks for the patch, it seems to be fixing the problem! Is this likely to be able to make it into 3.6? cheers matt
Matthew, Boris, do you think that this bug could/should be fixed for RC4?
+1 from me, this looks like a safe change. Up to Boris on whether it's ok to push this patch at this stage of the release though.
Boris, do you think we could fix this for RC4?
Could you attach a version of the patch without formatting changes? Is this a regression?
Created attachment 170590 [details] same patch without auto formatting
(In reply to comment #7) > Could you attach a version of the patch without formatting changes? Done. > Is this a regression? No, it's no regression bug.
What I'm just realising is that with my patch we might not always detach the validationStatusProviderTargetsListener within the DialogPageSupport#dispose() method on the target observable of a Binding (in case the Binding is already disposed) which might lead to problems.
I would recommend not fixing in RC4. If we have lived with this for a whole release (probably longer), it rarely qualifies as something that needs fixing just before a release. Is there a workaround that Matt could be using?
> Is there a workaround that Matt could be using? A workaround would be much appreciated. I can't override the class and dispose() method due to the private variables used within the DialogPageSupport. As it stands, with this issue, i have to cancel all wizards twice to remove them.
Could you make your own copy of WizardPageSupport/DialogPageSupport with a fix? After all, it's just a helper class.
(In reply to comment #13) > Could you make your own copy of WizardPageSupport/DialogPageSupport with a fix? > After all, it's just a helper class. I did think that may be an option. Its only 2 classes. Would this fix make it into 3.6 SR1 then?
Sorry for the delay, Matt. Another option might also be to make sure that the ValidationStatusProvider#getTargets() method does not return null after disposal. The only ValidationStatusProvider of the data binding framework which does this is MultiValidator so you might override MultiValidator (you must extend it anyway) and return an empty list instead of null in case the MultiValidator is disposed (see MultiValidator#isDisposed()).
(In reply to comment #14) > (In reply to comment #13) > > Could you make your own copy of WizardPageSupport/DialogPageSupport with a fix? > > After all, it's just a helper class. > > I did think that may be an option. Its only 2 classes. Would this fix make it > into 3.6 SR1 then? Yes, fixing for 3.6.1 shouldn't be a problem.
Thanks for the updates. Overriding the MultiValidator sounds interesting. ill have a look at that. Fixing for 3.6.1 would be much appreciated! Thanks.
(In reply to comment #17) > Thanks for the updates. > > Overriding the MultiValidator sounds interesting. ill have a look at that. > > Fixing for 3.6.1 would be much appreciated! Thanks. Interesting, i wrote that above comment but it appears my partner was logged in! oops. Matt
Adding the following to the MultiValidator stops the NPE occuring. Thanks @Override public IObservableList getTargets() { /** * BUGFIX: https://bugs.eclipse.org/bugs/show_bug.cgi?id=312785 */ if( isDisposed() ) { return new ObservableList(Collections.emptyList(), null) { }; } return super.getTargets(); }
(In reply to comment #19) > Adding the following to the MultiValidator stops the NPE occuring. Thanks I hope this temporary fix is OK for you for the time being. BTW, you might also use Observables#emptyObservableList().
> BTW, you might also use Observables#emptyObservableList(). aha... i was looking for something like that, but couldn't find it. Thanks for the tip!
Ovidio, it looks like we're pretty close on this one, except we need a unit test for the TitleAreaDialog part. Can we push this through for M3?
Ovido — I'd like to apply this patch. Would it be possible for you to sign the Eclipse Contributors Agreement (https://wiki.eclipse.org/ECA)?
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. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. 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.