]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge of (#9197) to Vaadin 7.
authorAnna Koskinen <anna@vaadin.com>
Fri, 1 Feb 2013 09:34:05 +0000 (11:34 +0200)
committerAnna Koskinen <anna@vaadin.com>
Fri, 1 Feb 2013 13:26:34 +0000 (15:26 +0200)
Fix IE memory leak when closing subwindows.

Change-Id: I7205bee96d172e84906aac1456b2523c56302d3b

client/src/com/vaadin/client/ui/VWindow.java
uitest/src/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java [new file with mode: 0644]

index 56dc22908e3cd3ceea17ac05a006118e42318422..bd9493c76109566541d54555992f0aff5dd54497 100644 (file)
@@ -458,6 +458,11 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
 
     private void hideModalityCurtain() {
         modalityCurtain.removeFromParent();
+        if (BrowserInfo.get().isIE()) {
+            // IE leaks memory in certain cases unless we release the reference
+            // (#9197)
+            modalityCurtain = null;
+        }
     }
 
     /*
diff --git a/uitest/src/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java b/uitest/src/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java
new file mode 100644 (file)
index 0000000..dcaabf9
--- /dev/null
@@ -0,0 +1,68 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class TableInSubWindowMemoryLeak extends TestBase {
+
+    @Override
+    public void setup() {
+        final Label label = new Label("Hello Vaadin user");
+        addComponent(label);
+        final Button openButton = new Button("open me");
+        openButton.addClickListener(new ClickListener() {
+
+            public void buttonClick(final ClickEvent event) {
+                final Window window = new Window("Simple Window");
+                window.setModal(true);
+                window.setHeight("200px");
+                window.setWidth("200px");
+                final Table table = new Table();
+                window.setContent(table);
+                UI.getCurrent().addWindow(window);
+                window.addCloseListener(new CloseListener() {
+                    public void windowClose(final CloseEvent e) {
+                        window.setContent(new Label());
+                        UI.getCurrent().removeWindow(window);
+                    }
+                });
+            }
+        });
+        addComponent(openButton);
+
+        final Button openButton2 = new Button("open me without Table");
+        openButton2.addClickListener(new ClickListener() {
+            public void buttonClick(final ClickEvent event) {
+                final Window window = new Window("Simple Window");
+                window.setModal(true);
+                window.setHeight("200px");
+                window.setWidth("200px");
+                UI.getCurrent().addWindow(window);
+                window.addCloseListener(new CloseListener() {
+                    public void windowClose(final CloseEvent e) {
+                        UI.getCurrent().removeWindow(window);
+                    }
+                });
+            }
+        });
+        addComponent(openButton2);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "IE 8 leaks memory with a subwindow containing a Table";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 9197;
+    }
+}