diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-02-14 09:45:36 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-02-14 09:45:36 +0000 |
commit | ce3475d5b768f76a75ce8e1f934cb8079df8f148 (patch) | |
tree | 0b9f5ee443aa8c50a20ce3c4b4e5585f85d000fc | |
parent | 87b3df113b41ebbff84087fffd897ed70fe045dc (diff) | |
parent | a4b5aaf7454f3f54c6b4fd8be846b7f8b0879ab9 (diff) | |
download | vaadin-framework-ce3475d5b768f76a75ce8e1f934cb8079df8f148.tar.gz vaadin-framework-ce3475d5b768f76a75ce8e1f934cb8079df8f148.zip |
Merge "Fixed NPE when a connector is no longer available (#11015)" into 7.0
-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); } |