diff options
author | Artur Signell <artur@vaadin.com> | 2013-02-12 11:04:01 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-02-13 12:12:10 +0200 |
commit | a4b5aaf7454f3f54c6b4fd8be846b7f8b0879ab9 (patch) | |
tree | 53be41409d8c0693d17777f2efa1005dce6f495b | |
parent | 03e620287b910e6f3f0d03c369f2eaa9a6d15346 (diff) | |
download | vaadin-framework-a4b5aaf7454f3f54c6b4fd8be846b7f8b0879ab9.tar.gz vaadin-framework-a4b5aaf7454f3f54c6b4fd8be846b7f8b0879ab9.zip |
Fixed NPE when a connector is no longer available (#11015)
Change-Id: Ie057beb80474546e08bb27a540773ae9f89b55a2
-rw-r--r-- | client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java index 4c46846d14..2ce45623d0 100644 --- a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java +++ b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java @@ -410,41 +410,73 @@ public class LayoutDependencyTree { public void setNeedsMeasure(ComponentConnector connector, boolean needsMeasure) { - setNeedsMeasure(connector.getConnectorId(), needsMeasure); + setNeedsHorizontalMeasure(connector, needsMeasure); + setNeedsVerticalMeasure(connector, needsMeasure); } public void setNeedsMeasure(String connectorId, boolean needsMeasure) { - setNeedsHorizontalMeasure(connectorId, needsMeasure); - setNeedsVerticalMeasure(connectorId, needsMeasure); + ComponentConnector connector = (ComponentConnector) ConnectorMap.get( + connection).getConnector(connectorId); + if (connector == null) { + return; + } + + setNeedsMeasure(connector, needsMeasure); } public void setNeedsHorizontalMeasure(ComponentConnector connector, boolean needsMeasure) { - setNeedsHorizontalMeasure(connector.getConnectorId(), needsMeasure); + LayoutDependency dependency = getDependency(connector, HORIZONTAL); + dependency.setNeedsMeasure(needsMeasure); } public void setNeedsHorizontalMeasure(String connectorId, boolean needsMeasure) { - LayoutDependency dependency = getDependency(connectorId, HORIZONTAL); - dependency.setNeedsMeasure(needsMeasure); + // Ensure connector exists + ComponentConnector connector = (ComponentConnector) ConnectorMap.get( + connection).getConnector(connectorId); + if (connector == null) { + return; + } + + setNeedsHorizontalMeasure(connector, needsMeasure); } public void setNeedsVerticalMeasure(ComponentConnector connector, boolean needsMeasure) { - setNeedsVerticalMeasure(connector.getConnectorId(), needsMeasure); + LayoutDependency dependency = getDependency(connector, VERTICAL); + dependency.setNeedsMeasure(needsMeasure); } public void setNeedsVerticalMeasure(String connectorId, boolean needsMeasure) { - LayoutDependency dependency = getDependency(connectorId, VERTICAL); - dependency.setNeedsMeasure(needsMeasure); + // Ensure connector exists + ComponentConnector connector = (ComponentConnector) ConnectorMap.get( + connection).getConnector(connectorId); + if (connector == null) { + return; + } + + setNeedsVerticalMeasure(connector, needsMeasure); + } + + private LayoutDependency getDependency(ComponentConnector connector, + int direction) { + return getDependency(connector.getConnectorId(), connector, direction); } private LayoutDependency getDependency(String connectorId, int direction) { + return getDependency(connectorId, null, direction); + } + + private LayoutDependency getDependency(String connectorId, + ComponentConnector connector, int direction) { FastStringMap<LayoutDependency> dependencies = dependenciesInDirection[direction]; LayoutDependency dependency = dependencies.get(connectorId); if (dependency == null) { - ComponentConnector connector = (ComponentConnector) ConnectorMap - .get(connection).getConnector(connectorId); + if (connector == null) { + connector = (ComponentConnector) ConnectorMap.get(connection) + .getConnector(connectorId); + } dependency = new LayoutDependency(connector, direction); dependencies.put(connectorId, dependency); } |