summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorPoommetee Ketson <poommetee@protonmail.com>2017-09-12 04:19:26 +0700
committerGitHub <noreply@github.com>2017-09-12 04:19:26 +0700
commit5edb3b6ee4ccc10fa8cb0dc5a82889aacda04ad7 (patch)
tree2b752da74729950f7942c6ca145cc1cb2ef11425 /scene
parentea5231fdf406b7f2e4050761e3d383061216b4ec (diff)
parentebee9898ca71a7388412225fccaf460c258c6940 (diff)
Merge pull request #11167 from bojidar-bg/9547-fix-metadata-duplication
Fix duplication of nodes resulting in shared metadata
Diffstat (limited to 'scene')
-rwxr-xr-xscene/main/node.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index c3d9d97c5a..a543dba9cb 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2117,7 +2117,15 @@ Node *Node::_duplicate(int p_flags) const {
if (!(p_flags & DUPLICATE_SCRIPTS) && name == "script/script")
continue;
- node->set(name, get(name));
+ Variant value = get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+
+ node->set(name, value);
}
node->set_name(get_name());
@@ -2199,7 +2207,16 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set(name, get(name));
+
+ Variant value = get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+
+ node->set(name, value);
}
node->set_name(get_name());