1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 07:05:24 +02:00

[243263] NPE on expanding a filter - regressed back to original wrong window code since: 1) we should be returning null when on the wrong thread

2)  several consumers don't expect null so for 3.0.1 we should keep the original behaviour
This commit is contained in:
David McKnight 2008-08-18 20:19:55 +00:00
parent 57cafc2f90
commit 584b6cdccf

View file

@ -116,19 +116,24 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
// otherwise, get a list of all the windows, and simply return the first one
// KM: why do we need this??
else {
final IWorkbench workbench = wb;
// for bug 244454, this ends up returning the wrong window
// the correct solution involves:
// - returning null when called from a non-UI thread
// - making sure that callers handle and understand that
// - null may be returned
//
// but for now (in 3.0.1) we're leaving this because
// there are several callers that don't expect null and
// will fail if we make the change now
//
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
// do this in a runnable so we can get the right window on the main thread
class GetActiveWindow implements Runnable {
public IWorkbenchWindow _activeWindow = null;
public void run()
{
_activeWindow = workbench.getActiveWorkbenchWindow();
}
if (windows != null && windows.length > 0) {
return windows[0];
}
else {
return null;
}
GetActiveWindow runnable = new GetActiveWindow();
wb.getDisplay().syncExec(runnable);
return runnable._activeWindow;
}
}