Skip to content

Commit 391dafc

Browse files
committed
Dispose leftover shells in WorkbenchContextExtension cleanup
The dispose() method calls wb.close() which removes GUI for application windows, but does not dispose shells created as side effects (e.g. PartRenderingEngine's limbo shell). These accumulate across test methods, causing many unexpected windows to open. Explicitly dispose all remaining shells after wb.close() to ensure a clean state between test methods. See #3893
1 parent e6c1136 commit 391dafc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/rules/WorkbenchContextExtension.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.eclipse.e4.ui.workbench.modeling.EModelService;
3131
import org.eclipse.e4.ui.workbench.swt.DisplayUISynchronize;
3232
import org.eclipse.swt.widgets.Display;
33+
import org.eclipse.swt.widgets.Shell;
3334
import org.junit.jupiter.api.extension.AfterEachCallback;
3435
import org.junit.jupiter.api.extension.BeforeEachCallback;
3536
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -90,6 +91,15 @@ protected void dispose() {
9091
wb.close();
9192
}
9293

94+
// Dispose any remaining shells that were not cleaned up by wb.close(),
95+
// such as PartRenderingEngine's limbo shell
96+
Display display = Display.getDefault();
97+
for (Shell shell : display.getShells()) {
98+
if (!shell.isDisposed()) {
99+
shell.dispose();
100+
}
101+
}
102+
93103
ContextInjectionFactory.setDefault(null);
94104

95105
// Workaround, enforce uninjection on the UIEventTopic provider from context

0 commit comments

Comments
 (0)