Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 325261

Summary: [Wizards] NullPointerException in WizardDialog.updateButtons
Product: [Eclipse Project] Platform Reporter: Adriaan Peeters <apeeters>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: RESOLVED INVALID QA Contact: Prakash Rangaraj <prakash>
Severity: normal    
Priority: P3 CC: remy.suen
Version: 3.6   
Target Milestone: ---   
Hardware: All   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Adriaan Peeters CLA 2010-09-14 10:28:54 EDT
Build Identifier: 20100617-1415

When WizardDialog.updateButtons is called without a current page, a NullPointerException is thrown.

updateButtons should, similar to updateMessage, start with a null check of the currentPage variable.

Reproducible: Always
Comment 1 Prakash Rangaraj CLA 2010-09-17 01:27:24 EDT
Do you have a stack trace? I was wondering how is updateButtons() get called without the current page set
Comment 2 Adriaan Peeters CLA 2010-09-23 04:16:40 EDT
I do not have a concrete stack trace but I encountered this 'bug' in the following scenario.

I have a wizard that updates its buttons on changes in the underlying data model (using a listener). This data model might change before the wizard is open, hence triggering the listener which calls updateButtons. In this method currentPage is referenced, which is null.
Comment 3 Adriaan Peeters CLA 2010-09-23 04:22:17 EDT
A simplified stack trace follows:

java.lang.NullPointerException
	at org.eclipse.jface.wizard.WizardDialog.updateButtons(WizardDialog.java:1326)
        ...
        updateButtons is called somehow during createControl
        ...
	at com.example.WizardPage.createControl(WizardPage.java:32)
	at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:170)
	at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:734)
	at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:606)
	at org.eclipse.jface.window.Window.create(Window.java:431)
	at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
	at org.eclipse.jface.window.Window.open(Window.java:790)
Comment 4 Prakash Rangaraj CLA 2010-09-29 02:21:52 EDT
The updateButtons() sets the enablement of the back/next buttons. You cannot do this before the creation of all the wizard pages. So calling the updateButtons() in the wizardPage.createControl() method is not correct.

You can probably move the logic to the setVisible() method