Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2022 IBM Corporation and others.
* Copyright (c) 2003, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -152,7 +152,11 @@ protected void addListeners() {

@Override
protected void removeListeners() {
PDECore.getWorkspace().removeResourceChangeListener(this);
IWorkspace workspace = PDECore.getWorkspace();
if (bundleRootChangedListener != null) {
Arrays.stream(workspace.getRoot().getProjects()).forEach(this::removeBundleRootChangedListener);
}
workspace.removeResourceChangeListener(this);
super.removeListeners();
}

Expand Down Expand Up @@ -198,6 +202,9 @@ public boolean visit(IResourceDelta delta) throws CoreException {
if (addedOrOpened && bundleRootChangedListener != null) {
addBundleRootChangedListener(project);
}
if (delta.getKind() == IResourceDelta.REMOVED && bundleRootChangedListener != null) {
removeBundleRootChangedListener(project);
}
if (isInterestingProject(project) && addedOrOpened) {
createModel(project, true);
return false;
Expand Down Expand Up @@ -227,6 +234,13 @@ private void addBundleRootChangedListener(IProject project) {
pdeNode.addPreferenceChangeListener(bundleRootChangedListener);
}

private void removeBundleRootChangedListener(IProject project) {
IEclipsePreferences pdeNode = new ProjectScope(project).getNode(PDECore.PLUGIN_ID);
// Remove the preference change listener when the project is removed
// from the workspace to make it eligible for garbage collection
pdeNode.removePreferenceChangeListener(bundleRootChangedListener);
}

protected IPreferenceChangeListener createBundleRootChangeListener() {
return e -> {
if (PDEProject.BUNDLE_ROOT_PATH.equals(e.getKey()) && !isInRemovedBranch(e.getNode())) {
Expand Down
Loading