Monday, July 13, 2009

Look at the code and find NPE

NPE at IconAndMessageDialog.getSWTImage(). No line number.
How much time do you need to figure out what's wrong?

This bugzilla entry contains spoiler (comment 6, and solution, comment 10).

The challenge code is:

private Image getSWTImage(final int imageID) {
Shell shell = getShell();
final Display display;
if (shell == null || shell.isDisposed()) {
shell = getParentShell();
}
if (shell == null || shell.isDisposed()) {
display = Display.getCurrent();
} else {
display = shell.getDisplay();
}

final Image[] image = new Image[1];
display.syncExec(new Runnable() {
public void run() {
image[0] = display.getSystemImage(imageID);
}
});

return image[0];

}



BTW. Does anybody knows good plug-in to export html code?

1 comment:

Lars Vogel said...

I'm not sure what you mean by "plug-in to export html" but I here you find a little example which allows you to export a selected Java file as HTML: http://www.vogella.de/articles/EclipsePlugIn/article.html#packageexplorer