Skip to content

Commit 9c1947b

Browse files
committed
GDExtension: Call startup callback only after reload is fully finished
1 parent c81fd6c commit 9c1947b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

core/extension/gdextension_manager.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ GDExtensionManager::LoadStatus GDExtensionManager::_load_extension_internal(cons
5555
gdextension_class_icon_paths[kv.key] = kv.value;
5656
}
5757

58+
if (p_first_load) {
59+
// On first load, we automatically do everything at once. For reload, we need to
60+
// defer this until a little later.
61+
_finish_load_extension(p_extension);
62+
}
63+
64+
return LOAD_STATUS_OK;
65+
}
66+
67+
void GDExtensionManager::_finish_load_extension(const Ref<GDExtension> &p_extension) {
5868
#ifdef TOOLS_ENABLED
5969
// Signals that a new extension is loaded so GDScript can register new class names.
6070
emit_signal("extension_loaded", p_extension);
@@ -67,8 +77,6 @@ GDExtensionManager::LoadStatus GDExtensionManager::_load_extension_internal(cons
6777
p_extension->startup_callback();
6878
}
6979
}
70-
71-
return LOAD_STATUS_OK;
7280
}
7381

7482
GDExtensionManager::LoadStatus GDExtensionManager::_unload_extension_internal(const Ref<GDExtension> &p_extension) {
@@ -186,6 +194,8 @@ GDExtensionManager::LoadStatus GDExtensionManager::reload_extension(const String
186194

187195
extension->finish_reload();
188196

197+
_finish_load_extension(extension);
198+
189199
return LOAD_STATUS_OK;
190200
#endif
191201
}

core/extension/gdextension_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class GDExtensionManager : public Object {
5757

5858
private:
5959
LoadStatus _load_extension_internal(const Ref<GDExtension> &p_extension, bool p_first_load);
60+
void _finish_load_extension(const Ref<GDExtension> &p_extension);
6061
LoadStatus _unload_extension_internal(const Ref<GDExtension> &p_extension);
6162

6263
#ifdef TOOLS_ENABLED

0 commit comments

Comments
 (0)