Skip to content

Commit

Permalink
Merge pull request godotengine#11013 from MednauN/master
Browse files Browse the repository at this point in the history
Fix duplication of node with script
  • Loading branch information
akien-mga authored Sep 21, 2017
2 parents 82f1328 + 521280e commit a1779c9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/*************************************************************************/
#include "node.h"

#include "core/core_string_names.h"
#include "instance_placeholder.h"
#include "io/resource_loader.h"
#include "message_queue.h"
Expand Down Expand Up @@ -2104,12 +2105,22 @@ Node *Node::_duplicate(int p_flags) const {

get_property_list(&plist);

StringName script_property_name = CoreStringNames::get_singleton()->_script;

if (p_flags & DUPLICATE_SCRIPTS) {
bool is_valid = false;
Variant script = get(script_property_name, &is_valid);
if (is_valid) {
node->set(script_property_name, script);
}
}

for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {

if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
if (!(p_flags & DUPLICATE_SCRIPTS) && name == "script/script")
if (name == script_property_name)
continue;

Variant value = get(name);
Expand Down

0 comments on commit a1779c9

Please sign in to comment.