| Summary: | NPE executing a Job | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Andreas Hoegger <Andreas.Hoegger> | ||||
| Component: | Workbench | Assignee: | Project Inbox <rap-inbox> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | Andreas.Hoegger | ||||
| Version: | 1.4 | ||||||
| Target Milestone: | 1.4 M7 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Andreas Hoegger
Andreas, could you provide a self-running snippet to reproduce it? Sure:
user the following code as your IEntryPoint.createUI() content.
Display display = new Display();
Shell shell = new Shell(display, SWT.NO_TRIM);
shell.setLayout(new GridLayout(1, false));
Button button = new Button(shell, SWT.PUSH);
button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false,
false));
button.setText("Test button");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
new Job(""){
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return Status.OK_STATUS;
}
}.schedule();
}
});
shell.setMaximized(true);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
return 0;
Thanks for the snippet... I can reproduce it now Created attachment 192545 [details]
Proposed patch
The JobManagerAdapter (initialized in WorkbenchPlugin#start ) connects the Job APIs with ProgressManager regardless the Workbench is created or not ( Workbench display is set in Workbench#createAndRunWorkbench() ). Thus, the display used by ProgressInfoItem#init ( PlatformUI.getWorkbench().getDisplay() ) is null. As this display is only used for getting the system color, I think it's safe to replace the PlatformUI.getWorkbench().getDisplay() with Display#getCurrent().
+1 works for me. Applied patch to CVS HEAD. |