From 95aedeaaf34517fe7666c16fea6bfcf3fa563656 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Wed, 1 Jun 2022 23:51:15 +0200 Subject: [PATCH] Clean up copyComponentsMaintainParent --- .../sf/openrocket/gui/main/RocketActions.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/RocketActions.java b/swing/src/net/sf/openrocket/gui/main/RocketActions.java index 83fb0cb92..ff1d94593 100644 --- a/swing/src/net/sf/openrocket/gui/main/RocketActions.java +++ b/swing/src/net/sf/openrocket/gui/main/RocketActions.java @@ -267,20 +267,10 @@ public class RocketActions { for (int i = 0; i < components.size(); i++) { if (components.contains(components.get(i).getParent())) { - RocketComponent oldChild = components.get(i); - RocketComponent oldParent = oldChild.getParent(); + RocketComponent originalParent = components.get(i).getParent(); + int originalParentIdx = components.indexOf(originalParent); - int index = components.indexOf(oldParent); - int childPos = oldParent.getChildPosition(oldChild); - - RocketComponent newChild = result.get(i); - RocketComponent newParent = result.get(index); - - // Add the newly copied child to the parent - newParent.addChild(newChild, childPos); - - // Remove the old child from the parent - newParent.removeChild(oldChild); + result.get(originalParentIdx).addChild(result.get(i)); } }