From 1baeeab1dbbb0f774c249bedc98b403bb5cd1c1f Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 23 Oct 2012 13:26:52 +0300 Subject: [PATCH] Fixed moving components from an outer AbsoluteLayout into an inner layout #10034 Change-Id: Ib635a02e2a4b2dd70623c221da4289b0ee7bed27 --- .../ui/absolutelayout/VAbsoluteLayout.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java b/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java index 04acb06c40..fbf534a5b5 100644 --- a/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java +++ b/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java @@ -305,6 +305,23 @@ public class VAbsoluteLayout extends ComplexPanel { for (Widget widget : getChildren()) { if (widget instanceof AbsoluteWrapper) { AbsoluteWrapper wrapper = (AbsoluteWrapper) widget; + + /* + * Cleanup old wrappers which have been left empty by other + * inner layouts moving the widget from the wrapper into their + * own hierarchy. This usually happens when a call to + * setWidget(widget) is done in an inner layout which + * automatically detaches the widget from the parent, in this + * case the wrapper, and re-attaches it somewhere else. This has + * to be done in the layout phase since the order of the + * hierarchy events are not defined. + */ + if (wrapper.getWidget() == null) { + wrapper.destroy(); + super.remove(wrapper); + continue; + } + Style wrapperStyle = wrapper.getElement().getStyle(); Style widgetStyle = wrapper.getWidget().getElement().getStyle(); if (widgetStyle.getHeight() != null @@ -341,6 +358,23 @@ public class VAbsoluteLayout extends ComplexPanel { for (Widget widget : getChildren()) { if (widget instanceof AbsoluteWrapper) { AbsoluteWrapper wrapper = (AbsoluteWrapper) widget; + + /* + * Cleanup old wrappers which have been left empty by other + * inner layouts moving the widget from the wrapper into their + * own hierarchy. This usually happens when a call to + * setWidget(widget) is done in an inner layout which + * automatically detaches the widget from the parent, in this + * case the wrapper, and re-attaches it somewhere else. This has + * to be done in the layout phase since the order of the + * hierarchy events are not defined. + */ + if (wrapper.getWidget() == null) { + wrapper.destroy(); + super.remove(wrapper); + continue; + } + Style wrapperStyle = wrapper.getElement().getStyle(); Style widgetStyle = wrapper.getWidget().getElement().getStyle(); -- 2.39.5