summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java12
-rw-r--r--client/src/com/vaadin/client/ui/orderedlayout/Slot.java10
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;
}