You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
Fix slow load/save of scenes with many instances of the same script
This commit is contained in:
@@ -360,7 +360,7 @@ PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this)
|
|||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(GDScriptLanguage::get_singleton(), Ref<Script>(this), p_this));
|
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(GDScriptLanguage::get_singleton(), Ref<Script>(this), p_this));
|
||||||
placeholders.insert(si);
|
placeholders.insert(si);
|
||||||
_update_exports();
|
_update_exports(nullptr, false, si);
|
||||||
return si;
|
return si;
|
||||||
#else
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -584,7 +584,7 @@ void GDScript::_update_doc() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
|
bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderScriptInstance *p_instance_to_update) {
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
|
||||||
static Vector<GDScript *> base_caches;
|
static Vector<GDScript *> base_caches;
|
||||||
@@ -721,16 +721,20 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placeholders.size()) { //hm :(
|
if ((changed || p_instance_to_update) && placeholders.size()) { //hm :(
|
||||||
|
|
||||||
// update placeholders if any
|
// update placeholders if any
|
||||||
Map<StringName, Variant> values;
|
Map<StringName, Variant> values;
|
||||||
List<PropertyInfo> propnames;
|
List<PropertyInfo> propnames;
|
||||||
_update_exports_values(values, propnames);
|
_update_exports_values(values, propnames);
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
|
for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
|
||||||
E->get()->update(propnames, values);
|
E->get()->update(propnames, values);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
p_instance_to_update->update(propnames, values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class GDScript : public Script {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool _update_exports(bool *r_err = nullptr, bool p_recursive_call = false);
|
bool _update_exports(bool *r_err = nullptr, bool p_recursive_call = false, PlaceHolderScriptInstance *p_instance_to_update = nullptr);
|
||||||
|
|
||||||
void _save_orphaned_subclasses();
|
void _save_orphaned_subclasses();
|
||||||
void _init_rpc_methods_properties();
|
void _init_rpc_methods_properties();
|
||||||
|
|||||||
@@ -2370,7 +2370,7 @@ void CSharpScript::_update_member_info_no_exports() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool CSharpScript::_update_exports() {
|
bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_update) {
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
bool is_editor = Engine::get_singleton()->is_editor_hint();
|
bool is_editor = Engine::get_singleton()->is_editor_hint();
|
||||||
if (is_editor) {
|
if (is_editor) {
|
||||||
@@ -2542,15 +2542,19 @@ bool CSharpScript::_update_exports() {
|
|||||||
if (is_editor) {
|
if (is_editor) {
|
||||||
placeholder_fallback_enabled = false;
|
placeholder_fallback_enabled = false;
|
||||||
|
|
||||||
if (placeholders.size()) {
|
if ((changed || p_instance_to_update) && placeholders.size()) {
|
||||||
// Update placeholders if any
|
// Update placeholders if any
|
||||||
Map<StringName, Variant> values;
|
Map<StringName, Variant> values;
|
||||||
List<PropertyInfo> propnames;
|
List<PropertyInfo> propnames;
|
||||||
_update_exports_values(values, propnames);
|
_update_exports_values(values, propnames);
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
|
for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
|
||||||
E->get()->update(propnames, values);
|
E->get()->update(propnames, values);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
p_instance_to_update->update(propnames, values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -3230,7 +3234,7 @@ PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_t
|
|||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this));
|
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this));
|
||||||
placeholders.insert(si);
|
placeholders.insert(si);
|
||||||
_update_exports();
|
_update_exports(si);
|
||||||
return si;
|
return si;
|
||||||
#else
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ private:
|
|||||||
void load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class);
|
void load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class);
|
||||||
bool _get_signal(GDMonoClass *p_class, GDMonoMethod *p_delegate_invoke, Vector<SignalParameter> ¶ms);
|
bool _get_signal(GDMonoClass *p_class, GDMonoMethod *p_delegate_invoke, Vector<SignalParameter> ¶ms);
|
||||||
|
|
||||||
bool _update_exports();
|
bool _update_exports(PlaceHolderScriptInstance *p_instance_to_update = nullptr);
|
||||||
|
|
||||||
bool _get_member_export(IMonoClassMember *p_member, bool p_inspect_export, PropertyInfo &r_prop_info, bool &r_exported);
|
bool _get_member_export(IMonoClassMember *p_member, bool p_inspect_export, PropertyInfo &r_prop_info, bool &r_exported);
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
|||||||
Reference in New Issue
Block a user