aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2012-09-24 10:28:58 (EDT)
committerOleg Besedin2012-09-24 10:29:41 (EDT)
commitd9d9f209f7f9a8d8a0c08381ee8f8bf51279fa2c (patch)
tree55edba344d34c33bb9e72d415593e7d162ad3a4e
parent5eebee131d1a422b291cd7b7115c76459f99da39 (diff)
downloadeclipse.platform.ui-d9d9f209f7f9a8d8a0c08381ee8f8bf51279fa2c.zip
eclipse.platform.ui-d9d9f209f7f9a8d8a0c08381ee8f8bf51279fa2c.tar.gz
eclipse.platform.ui-d9d9f209f7f9a8d8a0c08381ee8f8bf51279fa2c.tar.bz2
Bug 389250 - Lots of stuff leaked when closing and reopening views
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java
index a439075..84e1550 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java
@@ -14,8 +14,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
@@ -338,6 +340,7 @@ public class MenuManagerRenderer extends SWTPartRenderer {
public void cleanUp(MMenu menuModel) {
Collection<ContributionRecord> vals = modelContributionToRecord
.values();
+ List<ContributionRecord> disposedRecords = new ArrayList<ContributionRecord>();
for (ContributionRecord record : vals
.toArray(new ContributionRecord[vals.size()])) {
if (record.menuModel == menuModel) {
@@ -350,8 +353,20 @@ public class MenuManagerRenderer extends SWTPartRenderer {
}
record.generatedElements.clear();
record.sharedElements.clear();
+ disposedRecords.add(record);
}
}
+
+ // The cleanup() is called recursively via cleanUpCopy(), hence
+ // the need to do a separate pass to remove disposed records:
+ Iterator<Entry<MMenuElement, ContributionRecord>> iterator = modelContributionToRecord
+ .entrySet().iterator();
+ for (; iterator.hasNext();) {
+ Entry<MMenuElement, ContributionRecord> entry = iterator.next();
+ ContributionRecord record = entry.getValue();
+ if (disposedRecords.contains(record))
+ iterator.remove();
+ }
}
public void cleanUpCopy(ContributionRecord record, MMenuElement copy) {