1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 21:15:23 +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 // otherwise, get a list of all the windows, and simply return the first one
// KM: why do we need this?? // KM: why do we need this??
else { 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 if (windows != null && windows.length > 0) {
class GetActiveWindow implements Runnable { return windows[0];
public IWorkbenchWindow _activeWindow = null; }
public void run() else {
{ return null;
_activeWindow = workbench.getActiveWorkbenchWindow();
}
} }
GetActiveWindow runnable = new GetActiveWindow();
wb.getDisplay().syncExec(runnable);
return runnable._activeWindow;
} }
} }