diff options
author | Artur Signell <artur@vaadin.com> | 2015-07-12 20:11:41 +0300 |
---|---|---|
committer | Mika Murtojarvi <mika@vaadin.com> | 2015-09-15 10:51:02 +0300 |
commit | 18cf80534a98651510f2b743d215083206aea53a (patch) | |
tree | de9332299aef1f23b447c7f96940ae5faa8d6bbb /client | |
parent | efdc36027dec55e8b1084c7ea94ccb843b8a7c99 (diff) | |
download | vaadin-framework-18cf80534a98651510f2b743d215083206aea53a.tar.gz vaadin-framework-18cf80534a98651510f2b743d215083206aea53a.zip |
Backport fix for #16992 to Vaadin 7.5.
Change-Id: I4899aac895f061cffffaccc5b0e33f92bada28b0
Diffstat (limited to 'client')
3 files changed, 56 insertions, 11 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 5547b02895..24cfdf62b9 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -63,7 +63,6 @@ import com.google.gwt.user.client.Window.ClosingHandler; import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConfiguration.ErrorMessage; -import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.communication.HasJavaScriptConnectorHelper; @@ -1693,18 +1692,20 @@ public class ApplicationConnection implements HasHandlers { updatingState = false; - if (!onlyNoLayoutUpdates) { - Profiler.enter("Layout processing"); - try { - LayoutManager layoutManager = getLayoutManager(); + Profiler.enter("Layout processing"); + try { + LayoutManager layoutManager = getLayoutManager(); + if (!onlyNoLayoutUpdates) { layoutManager.setEverythingNeedsMeasure(); + } + if (layoutManager.isLayoutNeeded()) { layoutManager.layoutNow(); - } catch (final Throwable e) { - getLogger().log(Level.SEVERE, - "Error processing layouts", e); } - Profiler.leave("Layout processing"); + } catch (final Throwable e) { + getLogger() + .log(Level.SEVERE, "Error processing layouts", e); } + Profiler.leave("Layout processing"); if (ApplicationConfiguration.isDebugMode()) { Profiler.enter("Dumping state changes to the console"); diff --git a/client/src/com/vaadin/client/LayoutManager.java b/client/src/com/vaadin/client/LayoutManager.java index 102e618f5e..2d10d0c082 100644 --- a/client/src/com/vaadin/client/LayoutManager.java +++ b/client/src/com/vaadin/client/LayoutManager.java @@ -1800,4 +1800,25 @@ public class LayoutManager { return Logger.getLogger(LayoutManager.class.getName()); } + /** + * Checks if there is something waiting for a layout to take place. + * + * @since 7.5.6 + * @return true if there are connectors waiting for measurement or layout, + * false otherwise + */ + public boolean isLayoutNeeded() { + if (!needsHorizontalLayout.isEmpty() || !needsVerticalLayout.isEmpty()) { + return true; + } + if (!needsMeasure.isEmpty()) { + return true; + } + + if (everythingNeedsMeasure) { + return true; + } + + return false; + } } diff --git a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java index 07bb6688e3..a4c5668948 100644 --- a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java +++ b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java @@ -17,6 +17,7 @@ package com.vaadin.client.ui.layout; import java.util.ArrayList; import java.util.Collection; +import java.util.logging.Logger; import com.google.gwt.core.client.JsArrayString; import com.vaadin.client.ApplicationConnection; @@ -500,6 +501,12 @@ public class LayoutDependencyTree { if (connector == null) { connector = (ComponentConnector) ConnectorMap.get(connection) .getConnector(connectorId); + if (connector == null) { + getLogger().warning( + "No connector found for id " + connectorId + + " while creating LayoutDependency"); + return null; + } } dependency = new LayoutDependency(connector, direction); dependencies.put(connectorId, dependency); @@ -531,7 +538,12 @@ public class LayoutDependencyTree { public void setNeedsHorizontalLayout(String connectorId, boolean needsLayout) { LayoutDependency dependency = getDependency(connectorId, HORIZONTAL); - dependency.setNeedsLayout(needsLayout); + if (dependency != null) { + dependency.setNeedsLayout(needsLayout); + } else { + getLogger().warning( + "No dependency found in setNeedsHorizontalLayout"); + } } /** @@ -549,7 +561,13 @@ public class LayoutDependencyTree { public void setNeedsVerticalLayout(String connectorId, boolean needsLayout) { LayoutDependency dependency = getDependency(connectorId, VERTICAL); - dependency.setNeedsLayout(needsLayout); + if (dependency != null) { + dependency.setNeedsLayout(needsLayout); + } else { + getLogger() + .warning("No dependency found in setNeedsVerticalLayout"); + } + } public void markAsHorizontallyLayouted(ManagedLayout layout) { @@ -736,4 +754,9 @@ public class LayoutDependencyTree { } return dependency.scrollingBoundary; } + + private static Logger getLogger() { + return Logger.getLogger(LayoutDependencyTree.class.getName()); + } + } |