diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-28 10:44:38 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-06-28 10:44:38 -0300 |
commit | 565bb3afcc207aea6608bb119e21c6833f1b87b3 (patch) | |
tree | 83546dabb69c87910a79bfff77304f30ad30cc75 | |
parent | 8e1c0f287db96f73c8715ac1fa387b430f3758ca (diff) |
Fix extends issue, closes #4026
-rw-r--r-- | modules/gdscript/gd_compiler.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index 7481eac620..d9bbe42979 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -1497,7 +1497,8 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa String sub = p_class->extends_class[i]; if (script->subclasses.has(sub)) { - script=script->subclasses[sub]; + Ref<Script> subclass = script->subclasses[sub]; //avoid reference from dissapearing + script=subclass; } else { _set_error("Could not find subclass: "+sub,p_class); @@ -1683,6 +1684,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa if (err) return err; + p_script->constants.insert(name,subclass); //once parsed, goes to the list of constants p_script->subclasses.insert(name,subclass); diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index e37a2ca155..99f349def5 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -874,6 +874,10 @@ GDScript::~GDScript() { memdelete( E->get() ); } + for (Map<StringName,Ref<GDScript> >::Element *E=subclasses.front();E;E=E->next()) { + E->get()->_owner=NULL; //bye, you are no longer owned cause I died + } + #ifdef DEBUG_ENABLED if (GDScriptLanguage::get_singleton()->lock) { GDScriptLanguage::get_singleton()->lock->lock(); |