From 9da1979af798324cbe1eea2b6adde0886774f73b Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 19 Feb 2013 11:04:55 +0200 Subject: Properly detach old connectors for repaintAll response (#11067) Change-Id: I6491a9b30ea4c0e4ff141497b9bd78e5d1c4c98c --- .../com/vaadin/client/ApplicationConnection.java | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 3157bd0685..8ecc90bdd5 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -1395,15 +1395,12 @@ public class ApplicationConnection { Profiler.leave("Handling locales"); Profiler.enter("Handling meta information"); - boolean repaintAll = false; ValueMap meta = null; if (json.containsKey("meta")) { VConsole.log(" * Handling meta information"); meta = json.getValueMap("meta"); if (meta.containsKey("repaintAll")) { - repaintAll = true; - uIConnector.getWidget().clear(); - getConnectorMap().clear(); + prepareRepaintAll(); if (meta.containsKey("invalidLayouts")) { validatingLayouts = true; } @@ -1532,6 +1529,37 @@ public class ApplicationConnection { } + /** + * Properly clean up any old stuff to ensure everything is properly + * reinitialized. + */ + private void prepareRepaintAll() { + String uiConnectorId = uIConnector.getConnectorId(); + if (uiConnectorId == null) { + // Nothing to clear yet + return; + } + + // Create fake server response that says that the uiConnector + // has no children + JSONObject fakeHierarchy = new JSONObject(); + fakeHierarchy.put(uiConnectorId, new JSONArray()); + JSONObject fakeJson = new JSONObject(); + fakeJson.put("hierarchy", fakeHierarchy); + ValueMap fakeValueMap = fakeJson.getJavaScriptObject().cast(); + + // Update hierarchy based on the fake response + ConnectorHierarchyUpdateResult connectorHierarchyUpdateResult = updateConnectorHierarchy(fakeValueMap); + + // Send hierarchy events based on the fake update + sendHierarchyChangeEvents(connectorHierarchyUpdateResult.events); + + // Unregister all the old connectors that have now been removed + unregisterRemovedConnectors(); + + getLayoutManager().cleanMeasuredSizes(); + } + private void updateCaptions( Collection pendingStateChangeEvents, Collection parentChanged) { -- cgit v1.2.3