Skip to content

Commit 23d4b86

Browse files
deepika-ulaeubi
authored andcommitted
Added guards to safely handle cases when Display is null or disposed.
1 parent dc1eea9 commit 23d4b86

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WorkbenchPlugin.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2018 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -1175,15 +1175,25 @@ public static boolean isSplashHandleSpecified() {
11751175
*/
11761176
public static Shell getSplashShell(Display display)
11771177
throws NumberFormatException, IllegalArgumentException {
1178+
if (display == null || display.isDisposed()) {
1179+
return null;
1180+
}
11781181
Shell splashShell = (Shell) display.getData(DATA_SPLASH_SHELL);
1179-
if (splashShell != null)
1182+
if (splashShell != null) {
1183+
if (splashShell.isDisposed()) {
1184+
return null;
1185+
}
11801186
return splashShell;
1187+
}
11811188

11821189
String splashHandle = System.getProperty(PROP_SPLASH_HANDLE);
11831190
if (splashHandle == null) {
11841191
return null;
11851192
}
11861193

1194+
if (display.isDisposed()) {
1195+
return null;
1196+
}
11871197
splashShell = Shell.internal_new(display, Long.parseLong(splashHandle));
11881198

11891199
display.setData(DATA_SPLASH_SHELL, splashShell);

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/services/WorkbenchSourceProvider.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2009, 2015 IBM Corporation and others.
2+
* Copyright (c) 2009, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -403,7 +403,16 @@ private ShowInContext getContext(IWorkbenchPart sourcePart) {
403403
}
404404

405405
private IWorkbenchWindow getActiveWindow() {
406-
final Shell newActiveShell = workbench.getDisplay().getActiveShell();
406+
Display display = workbench.getDisplay();
407+
if (display == null || display.isDisposed()) {
408+
return null;
409+
}
410+
411+
final Shell newActiveShell = display.getActiveShell();
412+
if (newActiveShell == null || newActiveShell.isDisposed()) {
413+
return null;
414+
}
415+
407416
final IContextService contextService = workbench.getService(IContextService.class);
408417
if (contextService != null) {
409418
final int shellType = contextService.getShellType(newActiveShell);

0 commit comments

Comments
 (0)