From cf17f0a5f2b1b99a1f371c8b86250ab7f6ebf9e5 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Mon, 6 Jan 2025 17:01:05 +0100 Subject: [PATCH] FindReplaceOverlay: avoid exception while closing workbench window #2666 When closing a workbench window while a find/replace overlay is open and one of the input fields (find/replace) has focus, an exception is thrown. This is caused by the FindReplaceOverlay trying to reactive shortcuts of the underlying editor while the input field is losing focus, but the handler service to perform the activation in is already disposed. Since there is no direct way of determining the underlying handler service from the overlay to identify whether it is already disposed, this change makes the overlay simply check for the workbench window currently being closed. This is reasonable as the reactivation of handlers is unnecessary if the underlying window is closed anyway. Fixes https://github.com/eclipse-platform/eclipse.platform.ui/pull/2666 --- .../ui/internal/findandreplace/overlay/FindReplaceOverlay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java index 78b22e07c60..ff9e0ccbcc2 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java @@ -172,7 +172,7 @@ public void focusLost(FocusEvent e) { * boolean) */ private void setTextEditorActionsActivated(boolean state) { - if (!(targetPart instanceof AbstractTextEditor)) { + if (!(targetPart instanceof AbstractTextEditor) || targetPart.getSite().getWorkbenchWindow().isClosing()) { return; } if (targetPart.getSite() instanceof MultiPageEditorSite multiEditorSite) {