OSDN Git Service

Ensure that deletion hook is only run on valid parents
authorTor Norbye <tnorbye@google.com>
Sat, 1 Oct 2011 04:00:43 +0000 (21:00 -0700)
committerTor Norbye <tnorbye@google.com>
Sat, 1 Oct 2011 04:19:37 +0000 (21:19 -0700)
There's now a "deletion hook" for ViewRules where they get a chance to
clean up after a set of children have been deleted. This changeset
guards against the case where the parent reference was null.

Change-Id: I3eef328ec5450a15588b29fff1d0d834388c4cde

eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ClipboardSupport.java

index 2c91b74..d431653 100644 (file)
@@ -210,12 +210,14 @@ public class ClipboardSupport {
                 for (SelectionItem cs : selection) {
                     NodeProxy node = cs.getNode();
                     INode parent = node.getParent();
-                    List<INode> children = clusters.get(parent);
-                    if (children == null) {
-                        children = new ArrayList<INode>();
-                        clusters.put((NodeProxy) parent, children);
+                    if (parent != null) {
+                        List<INode> children = clusters.get(parent);
+                        if (children == null) {
+                            children = new ArrayList<INode>();
+                            clusters.put((NodeProxy) parent, children);
+                        }
+                        children.add(node);
                     }
-                    children.add(node);
                 }
 
                 // Notify parent views about children getting deleted