]> source.dussan.org Git - vaadin-framework.git/commitdiff
Unregister dependencies during unregister to avoid leaks
authorLeif Åstrand <leif@vaadin.com>
Sat, 7 Apr 2012 08:30:22 +0000 (11:30 +0300)
committerLeif Åstrand <leif@vaadin.com>
Sat, 7 Apr 2012 08:30:22 +0000 (11:30 +0300)
src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java
src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java
src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java
src/com/vaadin/terminal/gwt/client/ui/TwinColSelectConnector.java
src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java

index 7ae6aff7f55a5c9e9d1f9e0412f2538db28df1c6..29cce052f0d6b9e01692982de50ae47fb209a6e1 100644 (file)
@@ -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();
index 1aad705109ce9c68d5ac8d9dccd22f1787b6e4f1..de0f6d9368137ef79c6a0ab66bb8074bc00ad596 100644 (file)
@@ -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();
index 11888f69aa233e109793bbf2a1aa84a90a01fb23..ebfdcbcfa2f72128ac9a55f853b2741f6fdb4885 100644 (file)
@@ -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;
index 55e75879ca44ce03ccd414e84417244e65172c69..449f4f51fe86aef4ff8ad60e1adbf7c8e69251e1 100644 (file)
@@ -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);
index 91299405944c7ebc8aa603badf25e97531a15bbe..043c3ee04128e496fc002cea1de7f7175bef1403 100644 (file)
@@ -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;