Skip to content

Commit 2a8e311

Browse files
tobias-melcheriloveeclipse
authored andcommitted
Remove IPropertyChangeListener registration in dispose method of editor
1 parent 388d0f3 commit 2a8e311

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/part/EditorPart.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,12 @@ protected final void checkSite(IWorkbenchPartSite site) {
291291
Assert.isTrue(site instanceof IEditorSite, "The site for an editor must be an IEditorSite"); //$NON-NLS-1$
292292
}
293293

294+
@Override
295+
public void dispose() {
296+
if (compatibilityTitleListener != null) {
297+
removePropertyListener(compatibilityTitleListener);
298+
compatibilityTitleListener = null;
299+
}
300+
super.dispose();
301+
}
294302
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/part/MultiPageEditorPart.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,21 @@ public abstract class MultiPageEditorPart extends EditorPart implements IPageCha
153153

154154
private ListenerList<IPageChangedListener> pageChangeListeners = new ListenerList<>(ListenerList.IDENTITY);
155155

156+
private org.eclipse.jface.util.IPropertyChangeListener propertyChangeListenerToUpdateContainer;
157+
156158
/**
157159
* Creates an empty multi-page editor with no pages and registers a
158160
* {@link PropertyChangeListener} to listen for changes to the editor's
159161
* preference..
160162
*/
161163
protected MultiPageEditorPart() {
162164
super();
163-
getAPIPreferenceStore().addPropertyChangeListener(event -> {
165+
propertyChangeListenerToUpdateContainer = event -> {
164166
if (isUpdateRequired(event)) {
165167
updateContainer();
166168
}
167-
});
169+
};
170+
getAPIPreferenceStore().addPropertyChangeListener(propertyChangeListenerToUpdateContainer);
168171
}
169172

170173
/**
@@ -526,6 +529,11 @@ protected IEditorSite createSite(IEditorPart editor) {
526529
*/
527530
@Override
528531
public void dispose() {
532+
IPreferenceStore store = getAPIPreferenceStore();
533+
if (propertyChangeListenerToUpdateContainer != null) {
534+
store.removePropertyChangeListener(propertyChangeListenerToUpdateContainer);
535+
propertyChangeListenerToUpdateContainer = null;
536+
}
529537
if (getSite() != null) {
530538
deactivateSite(true, false);
531539
}

0 commit comments

Comments
 (0)