diff options
author | Henri Sara <hesara@vaadin.com> | 2014-02-17 10:27:37 +0200 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2014-02-17 10:27:37 +0200 |
commit | 6f21052f2d952fd614c22b11e350e404a40761bb (patch) | |
tree | ade858183298371cb17d798d72e71b03ac265661 /client/src | |
parent | 3b327f6131166d3b503a55b7e91b853d179a3595 (diff) | |
download | vaadin-framework-6f21052f2d952fd614c22b11e350e404a40761bb.tar.gz vaadin-framework-6f21052f2d952fd614c22b11e350e404a40761bb.zip |
Eliminate spacing memory leak on client (#13315)
Change-Id: I432ae4a04d74826dd1cce108177bd503774a8463
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java | 12 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/orderedlayout/Slot.java | 10 |
2 files changed, 14 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index ec4307e50b..8ee1921ed7 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -297,9 +297,9 @@ public abstract class AbstractOrderedLayoutConnector extends // remove spacing as it is exists as separate elements that cannot be // removed easily after reordering the contents - Profiler.enter("AOLC.onConnectorHierarchyChange addOrMoveSlot temporarily remove spacing"); + Profiler.enter("AOLC.onConnectorHierarchyChange temporarily remove spacing"); layout.setSpacing(false); - Profiler.leave("AOLC.onConnectorHierarchyChange addOrMoveSlot temporarily remove spacing"); + Profiler.leave("AOLC.onConnectorHierarchyChange temporarily remove spacing"); for (ComponentConnector child : getChildComponents()) { Profiler.enter("AOLC.onConnectorHierarchyChange add children"); @@ -317,12 +317,12 @@ public abstract class AbstractOrderedLayoutConnector extends } // re-add spacing for the elements that should have it - Profiler.enter("AOLC.onConnectorHierarchyChange addOrMoveSlot setSpacing"); + Profiler.enter("AOLC.onConnectorHierarchyChange setSpacing"); // spacings were removed above if (getState().spacing) { layout.setSpacing(true); } - Profiler.leave("AOLC.onConnectorHierarchyChange addOrMoveSlot setSpacing"); + Profiler.leave("AOLC.onConnectorHierarchyChange setSpacing"); for (ComponentConnector child : previousChildren) { Profiler.enter("AOLC.onConnectorHierarchyChange remove children"); @@ -332,9 +332,7 @@ public abstract class AbstractOrderedLayoutConnector extends if (slot.hasCaption()) { slot.setCaptionResizeListener(null); } - if (slot.getSpacingElement() != null) { - slot.setSpacingResizeListener(null); - } + slot.setSpacingResizeListener(null); child.removeStateChangeHandler(childStateChangeHandler); layout.removeWidget(child.getWidget()); } diff --git a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java index efa19895a8..d9037cda3c 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java @@ -165,7 +165,7 @@ public final class Slot extends SimplePanel { } /** - * Attached resize listeners to the widget, caption and spacing elements + * Attaches resize listeners to the widget, caption and spacing elements */ private void attachListeners() { if (getWidget() != null && layout.getLayoutManager() != null) { @@ -204,6 +204,8 @@ public final class Slot extends SimplePanel { lm.removeElementResizeListener(getWidget().getElement(), widgetResizeListener); } + // in many cases, the listener has already been removed by + // setSpacing(false) if (getSpacingElement() != null && spacingResizeListener != null) { lm.removeElementResizeListener(getSpacingElement(), spacingResizeListener); @@ -352,6 +354,12 @@ public final class Slot extends SimplePanel { */ getElement().getParentElement().insertBefore(spacer, getElement()); } else if (!spacing && spacer != null) { + // Remove listener before spacer to avoid memory leak + LayoutManager lm = layout.getLayoutManager(); + if (lm != null && spacingResizeListener != null) { + lm.removeElementResizeListener(spacer, spacingResizeListener); + } + spacer.removeFromParent(); spacer = null; } |