From c9bdf6d11ed33194559ab6c03b359242b9bceb63 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Sat, 7 Apr 2012 11:30:22 +0300 Subject: [PATCH] Unregister dependencies during unregister to avoid leaks --- .../client/ui/AbstractOrderedLayoutConnector.java | 14 ++++++++++++++ .../gwt/client/ui/GridLayoutConnector.java | 13 +++++++++++++ .../terminal/gwt/client/ui/PanelConnector.java | 11 ++++++++++- .../gwt/client/ui/TwinColSelectConnector.java | 6 ++++++ .../terminal/gwt/client/ui/WindowConnector.java | 14 +++++++++++--- 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java index 7ae6aff7f5..29cce052f0 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java @@ -69,6 +69,20 @@ public abstract class AbstractOrderedLayoutConnector extends getWidget().spacingMeasureElement); } + @Override + public void onUnregister() { + LayoutManager lm = getLayoutManager(); + + VMeasuringOrderedLayout layout = getWidget(); + lm.unregisterDependency(this, layout.spacingMeasureElement); + + // Unregister child caption listeners + for (ComponentConnector child : getChildren()) { + VLayoutSlot slot = layout.getSlotForChild(child.getWidget()); + slot.setCaption(null); + } + } + @Override public AbstractOrderedLayoutState getState() { return (AbstractOrderedLayoutState) super.getState(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java index 1aad705109..de0f6d9368 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java @@ -88,6 +88,19 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector getWidget().spacingMeasureElement); } + @Override + public void onUnregister() { + VGridLayout layout = getWidget(); + getLayoutManager().unregisterDependency(this, + layout.spacingMeasureElement); + + // Unregister caption size dependencies + for (ComponentConnector child : getChildren()) { + Cell cell = layout.widgetToCell.get(child.getWidget()); + cell.slot.setCaption(null); + } + } + @Override public GridLayoutState getState() { return (GridLayoutState) super.getState(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java index 11888f69aa..ebfdcbcfa2 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java @@ -16,7 +16,6 @@ import com.vaadin.terminal.gwt.client.LayoutManager; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; -import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.communication.RpcProxy; import com.vaadin.terminal.gwt.client.communication.ServerRpc; import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix; @@ -87,6 +86,16 @@ public class PanelConnector extends AbstractComponentContainerConnector layoutManager.registerDependency(this, panel.contentNode); } + @Override + public void onUnregister() { + VPanel panel = getWidget(); + LayoutManager layoutManager = getLayoutManager(); + + layoutManager.unregisterDependency(this, panel.captionNode); + layoutManager.unregisterDependency(this, panel.bottomDecoration); + layoutManager.unregisterDependency(this, panel.contentNode); + } + @Override public boolean delegateCaptionHandling() { return false; diff --git a/src/com/vaadin/terminal/gwt/client/ui/TwinColSelectConnector.java b/src/com/vaadin/terminal/gwt/client/ui/TwinColSelectConnector.java index 55e75879ca..449f4f51fe 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/TwinColSelectConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/TwinColSelectConnector.java @@ -33,6 +33,12 @@ public class TwinColSelectConnector extends OptionGroupBaseConnector implements getWidget().captionWrapper.getElement()); } + @Override + public void onUnregister() { + getLayoutManager().unregisterDependency(this, + getWidget().captionWrapper.getElement()); + } + @Override protected Widget createWidget() { return GWT.create(VTwinColSelect.class); diff --git a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java index 9129940594..043c3ee041 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java @@ -20,7 +20,6 @@ import com.vaadin.terminal.gwt.client.LayoutManager; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; -import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.communication.RpcProxy; import com.vaadin.terminal.gwt.client.communication.ServerRpc; import com.vaadin.terminal.gwt.client.ui.PanelConnector.PanelState; @@ -29,8 +28,8 @@ import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix; @Component(value = com.vaadin.ui.Window.class) public class WindowConnector extends AbstractComponentContainerConnector - implements Paintable, BeforeShortcutActionListener, SimpleManagedLayout, - PostLayoutListener, RequiresOverflowAutoFix { + implements Paintable, BeforeShortcutActionListener, + SimpleManagedLayout, PostLayoutListener, RequiresOverflowAutoFix { public interface WindowServerRPC extends ClickRPC, ServerRpc { } @@ -128,6 +127,15 @@ public class WindowConnector extends AbstractComponentContainerConnector getLayoutManager().registerDependency(this, getWidget().footer); } + @Override + public void onUnregister() { + LayoutManager lm = getLayoutManager(); + VWindow window = getWidget(); + lm.unregisterDependency(this, window.contentPanel.getElement()); + lm.unregisterDependency(this, window.header); + lm.unregisterDependency(this, window.footer); + } + public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { getWidget().id = getConnectorId(); getWidget().client = client; -- 2.39.5