diff options
author | John Ahlroos <john@vaadin.com> | 2013-02-21 16:46:07 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-02-22 09:01:01 +0000 |
commit | 7af5b3fceb75b6f505a9a6d0a843b788bb06d9a7 (patch) | |
tree | 4b57a86e982d792c7f6b32ecfaac5af43027ee1c /server/src/com/vaadin/ui/Tree.java | |
parent | daf34986db58e1c4b6a7da40581697079b434c07 (diff) | |
download | vaadin-framework-7af5b3fceb75b6f505a9a6d0a843b788bb06d9a7.tar.gz vaadin-framework-7af5b3fceb75b6f505a9a6d0a843b788bb06d9a7.zip |
Fixed another memory leak in Tree #11053
Change-Id: Idf45309b83dfe718fe6e58b6cf57b211eeb9e811
Diffstat (limited to 'server/src/com/vaadin/ui/Tree.java')
-rw-r--r-- | server/src/com/vaadin/ui/Tree.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index 219b39020b..32c5712f0f 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -414,6 +414,9 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, final Object id = itemIdMapper.get(keys[i]); if (id != null && isExpanded(id)) { expanded.remove(id); + if (expandedItemId == id) { + expandedItemId = null; + } fireCollapseEvent(id); } } @@ -841,6 +844,10 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, super.setContainerDataSource(new ContainerHierarchicalWrapper( newDataSource)); } + + // Ensure previous expanded items are cleaned up if they don't exist in + // the new container + cleanupExpandedItems(); } /* Expand event and listener */ @@ -1675,6 +1682,12 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, com.vaadin.data.Container.ItemSetChangeEvent event) { // Ensure removed items are cleaned up from expanded list + cleanupExpandedItems(); + + super.containerItemSetChange(event); + } + + private void cleanupExpandedItems() { for (Object expandedItemId : expanded) { if (getItem(expandedItemId) == null) { expanded.remove(expandedItemId); @@ -1683,8 +1696,5 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } } } - - super.containerItemSetChange(event); } - } |