Reworked how autoloads are load to make sure identifiers always exist, please check if this resolves bug #3156
This commit is contained in:
parent
c4cee22510
commit
5fca2bd4bc
2 changed files with 24 additions and 1 deletions
|
@ -1327,6 +1327,29 @@ bool Main::start() {
|
||||||
//autoload
|
//autoload
|
||||||
List<PropertyInfo> props;
|
List<PropertyInfo> props;
|
||||||
Globals::get_singleton()->get_property_list(&props);
|
Globals::get_singleton()->get_property_list(&props);
|
||||||
|
|
||||||
|
//first pass, add the constants so they exist before any script is loaded
|
||||||
|
for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
|
||||||
|
|
||||||
|
String s = E->get().name;
|
||||||
|
if (!s.begins_with("autoload/"))
|
||||||
|
continue;
|
||||||
|
String name = s.get_slicec('/',1);
|
||||||
|
String path = Globals::get_singleton()->get(s);
|
||||||
|
bool global_var=false;
|
||||||
|
if (path.begins_with("*")) {
|
||||||
|
global_var=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (global_var) {
|
||||||
|
for(int i=0;i<ScriptServer::get_language_count();i++) {
|
||||||
|
ScriptServer::get_language(i)->add_global_constant(name,Variant());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//second pass, load into global constants
|
||||||
for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
|
for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
|
||||||
|
|
||||||
String s = E->get().name;
|
String s = E->get().name;
|
||||||
|
@ -1374,7 +1397,6 @@ bool Main::start() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -534,6 +534,7 @@ public:
|
||||||
virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const;
|
virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const;
|
||||||
virtual void add_global_constant(const StringName& p_variable,const Variant& p_value);
|
virtual void add_global_constant(const StringName& p_variable,const Variant& p_value);
|
||||||
|
|
||||||
|
|
||||||
/* DEBUGGER FUNCTIONS */
|
/* DEBUGGER FUNCTIONS */
|
||||||
|
|
||||||
virtual String debug_get_error() const;
|
virtual String debug_get_error() const;
|
||||||
|
|
Loading…
Reference in a new issue