From: Tuukka Lehtonen Date: Fri, 3 Mar 2017 07:33:57 +0000 (+0200) Subject: Prevent NPE when comparing a node that is still without parent. X-Git-Tag: v1.28.0~74 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=f366bd2c87748ab72cb42f468cd1e72e1a1c9b6c Prevent NPE when comparing a node that is still without parent. refs #7062 Change-Id: I13990a8db66408c1bc3cab6e4da8ba7997220c1a --- diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java index 1a12210f0..749343217 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java @@ -1162,7 +1162,7 @@ public class ElementUtils { // If the previously available node is not a parent of the specified // node create a new node under the specified parent and set that // as the node of the specified element. - if (!node.getParent().equals(withParentNode)) { + if (!withParentNode.equals(node.getParent())) { node = nodeId != null ? withParentNode.getOrCreateNode(nodeId, nodeClass) : withParentNode.addNode(nodeClass); forElement.setHint(withNodeKey, node); if (nodeCreationCallback != null)