mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
GDExtension: Call startup callback only after reload is fully finished
This commit is contained in:
parent
c81fd6c512
commit
92d9227d4a
2 changed files with 11 additions and 2 deletions
|
@ -55,6 +55,10 @@ GDExtensionManager::LoadStatus GDExtensionManager::_load_extension_internal(cons
|
|||
gdextension_class_icon_paths[kv.key] = kv.value;
|
||||
}
|
||||
|
||||
return LOAD_STATUS_OK;
|
||||
}
|
||||
|
||||
void GDExtensionManager::_finish_load_extension(const Ref<GDExtension> &p_extension) {
|
||||
#ifdef TOOLS_ENABLED
|
||||
// Signals that a new extension is loaded so GDScript can register new class names.
|
||||
emit_signal("extension_loaded", p_extension);
|
||||
|
@ -67,8 +71,6 @@ GDExtensionManager::LoadStatus GDExtensionManager::_load_extension_internal(cons
|
|||
p_extension->startup_callback();
|
||||
}
|
||||
}
|
||||
|
||||
return LOAD_STATUS_OK;
|
||||
}
|
||||
|
||||
GDExtensionManager::LoadStatus GDExtensionManager::_unload_extension_internal(const Ref<GDExtension> &p_extension) {
|
||||
|
@ -134,6 +136,8 @@ GDExtensionManager::LoadStatus GDExtensionManager::load_extension_with_loader(co
|
|||
return status;
|
||||
}
|
||||
|
||||
_finish_load_extension(extension);
|
||||
|
||||
extension->set_path(p_path);
|
||||
gdextension_map[p_path] = extension;
|
||||
return LOAD_STATUS_OK;
|
||||
|
@ -186,6 +190,10 @@ GDExtensionManager::LoadStatus GDExtensionManager::reload_extension(const String
|
|||
|
||||
extension->finish_reload();
|
||||
|
||||
// Needs to come after reload is fully finished, so all objects using
|
||||
// extension classes are in a consistent state.
|
||||
_finish_load_extension(extension);
|
||||
|
||||
return LOAD_STATUS_OK;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
private:
|
||||
LoadStatus _load_extension_internal(const Ref<GDExtension> &p_extension, bool p_first_load);
|
||||
void _finish_load_extension(const Ref<GDExtension> &p_extension);
|
||||
LoadStatus _unload_extension_internal(const Ref<GDExtension> &p_extension);
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue