From dcc370da016fa8a95ef02b784b9a1439b845ea48 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 14 Dec 2010 13:21:17 +0000 Subject: fixes #6150, see also #6060, #6061 svn changeset:16501/svn branch:6.5 --- .../terminal/gwt/client/ApplicationConnection.java | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 7f72e745a9..ef850313e0 100755 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -138,6 +138,8 @@ public class ApplicationConnection { private Set zeroHeightComponents = null; + private Set unregistryBag = new HashSet(); + public ApplicationConnection() { view = GWT.create(VView.class); } @@ -973,6 +975,8 @@ public class ApplicationConnection { } } + purgeUnregistryBag(); + // TODO build profiling for widget impl loading time final long prosessingTime = (new Date().getTime()) @@ -1072,23 +1076,46 @@ public class ApplicationConnection { /** * Unregisters the given paintable; always use after removing a paintable. - * Does not actually remove the paintable from the DOM. + * This method does not remove the paintable from the DOM, but marks the + * paintable so that ApplicationConnection may clean up its references to + * it. Removing the widget from DOM is component containers responsibility. * * @param p * the paintable to remove */ public void unregisterPaintable(Paintable p) { + + // add to unregistry que + if (p == null) { VConsole.error("WARN: Trying to unregister null paintable"); return; } String id = getPid(p); - idToPaintableDetail.remove(id); + unregistryBag.add(id); if (p instanceof HasWidgets) { unregisterChildPaintables((HasWidgets) p); } } + private void purgeUnregistryBag() { + for (String id : unregistryBag) { + // check if can be cleaned + Widget component = (Widget) idToPaintableDetail.get(id) + .getComponent(); + if (!component.isAttached()) { + // clean reference from ac to paintable + idToPaintableDetail.remove(id); + } + /* + * else NOP : same component has been reattached to another parent + * or replaced by another component implementation. + */ + } + + unregistryBag.clear(); + } + /** * Unregisters a paintable and all it's child paintables recursively. Use * when after removing a paintable that contains other paintables. Does not -- cgit v1.2.3