Skip to content

Commit

Permalink
fixed a bug where saving a GDScript file crashed the editor
Browse files Browse the repository at this point in the history
I changed the loop in godotengine#8502, turns out it fixed the error I was facing but introduced a new one. This fixes both
  • Loading branch information
karroffel authored and amugana committed Jun 28, 2017
1 parent ff42bcb commit 849314a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modules/gdscript/gd_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,16 +1696,19 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
//same thing for placeholders
#ifdef TOOLS_ENABLED

for (Set<PlaceHolderScriptInstance *>::Element *P = E->get()->placeholders.front(); P; P = P->next()) {
while (E->get()->placeholders.size()) {
Object *obj = E->get()->placeholders.front()->get()->get_owner();

Object *obj = P->get()->get_owner();
//save instance info
List<Pair<StringName, Variant> > state;
if (obj->get_script_instance()) {

obj->get_script_instance()->get_property_state(state);
map[obj->get_instance_ID()] = state;
obj->set_script(RefPtr());
} else {
// no instance found. Let's remove it so we don't loop forever
E->get()->placeholders.erase(E->get()->placeholders.front()->get());
}
}
#endif
Expand Down

0 comments on commit 849314a

Please sign in to comment.