From: Artur Signell Date: Tue, 12 Feb 2013 09:04:01 +0000 (+0200) Subject: Fixed NPE when a connector is no longer available (#11015) X-Git-Tag: 7.0.1~30^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a4b5aaf7454f3f54c6b4fd8be846b7f8b0879ab9;p=vaadin-framework.git Fixed NPE when a connector is no longer available (#11015) Change-Id: Ie057beb80474546e08bb27a540773ae9f89b55a2 --- 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 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); }