diff options
author | Artur Signell <artur@vaadin.com> | 2016-10-15 22:05:51 +0300 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2016-12-09 09:39:00 +0200 |
commit | 7b957a5c378532b11ebfb66156c3a46898f9231b (patch) | |
tree | 5afbb3e50174dda1968c652a907b1e454bdf74fc | |
parent | cc64935345aa767e8cdb1f7b229b89060748e441 (diff) | |
download | vaadin-framework-7b957a5c378532b11ebfb66156c3a46898f9231b.tar.gz vaadin-framework-7b957a5c378532b11ebfb66156c3a46898f9231b.zip |
Allow a resize listener to fire a resize listener (#20338)
Change-Id: I6b045c3a693e88b3cba182ae9ea68cfa98c914b0
3 files changed, 49 insertions, 3 deletions
diff --git a/client/src/main/java/com/vaadin/client/LayoutManager.java b/client/src/main/java/com/vaadin/client/LayoutManager.java index ad0a3f8c38..878ac17901 100644 --- a/client/src/main/java/com/vaadin/client/LayoutManager.java +++ b/client/src/main/java/com/vaadin/client/LayoutManager.java @@ -350,9 +350,12 @@ public class LayoutManager { int firedListeners = 0; if (!listenersToFire.isEmpty()) { + HashSet<Element> listenersCopy = new HashSet<Element>( + listenersToFire); + listenersToFire.clear(); firedListeners = listenersToFire.size(); Profiler.enter("Layout fire resize events"); - for (Element element : listenersToFire) { + for (Element element : listenersCopy) { Collection<ElementResizeListener> listeners = elementResizeListeners .get(element); if (listeners != null) { @@ -393,8 +396,6 @@ public class LayoutManager { "Layout fire resize events - listeners not null"); } } - listenersToFire.clear(); - Profiler.leave("Layout fire resize events"); } diff --git a/uitest/src/main/java/com/vaadin/tests/layoutmanager/ConcurrentModificationUI.java b/uitest/src/main/java/com/vaadin/tests/layoutmanager/ConcurrentModificationUI.java new file mode 100644 index 0000000000..2a3370e381 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/layoutmanager/ConcurrentModificationUI.java @@ -0,0 +1,29 @@ +package com.vaadin.tests.layoutmanager; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Panel; +import com.vaadin.ui.UI; + +public class ConcurrentModificationUI extends UI { + + @Override + protected void init(VaadinRequest request) { + Panel panel = new Panel(); + setContent(panel); + + FormLayout form = new FormLayout(); + panel.setContent(form); + + HorizontalLayout horizLyt = new HorizontalLayout(); + form.addComponent(horizLyt); + + CssLayout cssLyt = new CssLayout(); + horizLyt.addComponent(cssLyt); + horizLyt.setComponentAlignment(cssLyt, Alignment.MIDDLE_LEFT); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/layoutmanager/ConcurrentModificationUITest.java b/uitest/src/test/java/com/vaadin/tests/layoutmanager/ConcurrentModificationUITest.java new file mode 100644 index 0000000000..4a64fc3173 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/layoutmanager/ConcurrentModificationUITest.java @@ -0,0 +1,16 @@ +package com.vaadin.tests.layoutmanager; + +import org.junit.Test; + +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class ConcurrentModificationUITest extends SingleBrowserTest { + + @Test + public void noExceptionWhenEnlarging() { + testBench().resizeViewPortTo(100, 100); + openTestURL("debug"); + testBench().resizeViewPortTo(200, 200); + assertNoErrorNotifications(); + } +} |