diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java index e253c0902b4..71751e69827 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java @@ -302,8 +302,6 @@ public FindReplaceAction(ResourceBundle bundle, String prefix, IWorkbenchPart wo Assert.isLegal(workbenchPart != null); fWorkbenchPart= workbenchPart; update(); - - hookDialogPreferenceListener(); } /** @@ -331,8 +329,6 @@ public FindReplaceAction(ResourceBundle bundle, String prefix, Shell shell, IFin fTarget= target; fShell= shell; update(); - - hookDialogPreferenceListener(); } /** @@ -354,8 +350,6 @@ public FindReplaceAction(ResourceBundle bundle, String prefix, IWorkbenchWindow super(bundle, prefix); fWorkbenchWindow= workbenchWindow; update(); - - hookDialogPreferenceListener(); } private void hookDialogPreferenceListener() { @@ -363,6 +357,11 @@ private void hookDialogPreferenceListener() { preferences.addPreferenceChangeListener(overlayDialogPreferenceListener); } + private void removeDialogPreferenceListener() { + IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(INSTANCE_SCOPE_NODE_NAME); + preferences.removePreferenceChangeListener(overlayDialogPreferenceListener); + } + @Override public void run() { if (fTarget == null) { @@ -420,12 +419,14 @@ private void showOverlayInEditor() { shellToUse = fShell; } overlay = new FindReplaceOverlay(shellToUse, fWorkbenchPart, fTarget); + hookDialogPreferenceListener(); FindReplaceOverlayFirstTimePopup.displayPopupIfNotAlreadyShown(shellToUse); } overlay.setPositionToTop(shouldPositionOverlayOnTop()); overlay.open(); + overlay.getShell().addDisposeListener(__ -> removeDialogPreferenceListener()); } @Override