From ce512b35c19a4e4c482c63374c22b7dee026d2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gilles=20Roudi=C3=A8re?= Date: Mon, 28 Feb 2022 14:50:43 +0100 Subject: [PATCH] Reorder native extension types initialization, initializing editor last --- core/extension/gdnative_interface.h | 2 +- core/extension/native_extension.cpp | 1 + core/extension/native_extension.h | 2 +- doc/classes/NativeExtension.xml | 4 +++- main/main.cpp | 15 ++++++++------- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h index a2e0c7cc734..62934d1d733 100644 --- a/core/extension/gdnative_interface.h +++ b/core/extension/gdnative_interface.h @@ -460,8 +460,8 @@ typedef enum { GDNATIVE_INITIALIZATION_CORE, GDNATIVE_INITIALIZATION_SERVERS, GDNATIVE_INITIALIZATION_SCENE, - GDNATIVE_INITIALIZATION_EDITOR, GDNATIVE_INITIALIZATION_DRIVER, + GDNATIVE_INITIALIZATION_EDITOR, GDNATIVE_MAX_INITIALIZATION_LEVEL, } GDNativeInitializationLevel; diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index e1db99fe5d1..325ccec6c4f 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -325,6 +325,7 @@ void NativeExtension::_bind_methods() { BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_CORE); BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_SERVERS); BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_SCENE); + BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_DRIVER); BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_EDITOR); } diff --git a/core/extension/native_extension.h b/core/extension/native_extension.h index b98e4925d2e..ebfedfb29af 100644 --- a/core/extension/native_extension.h +++ b/core/extension/native_extension.h @@ -71,8 +71,8 @@ public: INITIALIZATION_LEVEL_CORE, INITIALIZATION_LEVEL_SERVERS, INITIALIZATION_LEVEL_SCENE, - INITIALIZATION_LEVEL_EDITOR, INITIALIZATION_LEVEL_DRIVER, + INITIALIZATION_LEVEL_EDITOR, }; bool is_library_open() const; diff --git a/doc/classes/NativeExtension.xml b/doc/classes/NativeExtension.xml index e5e11c1c953..ccdbb617abe 100644 --- a/doc/classes/NativeExtension.xml +++ b/doc/classes/NativeExtension.xml @@ -43,7 +43,9 @@ - + + + diff --git a/main/main.cpp b/main/main.cpp index 246a26025c4..da79020bac4 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -425,6 +425,7 @@ Error Main::test_setup() { ResourceLoader::load_path_remaps(); register_scene_types(); + register_driver_types(); #ifdef TOOLS_ENABLED ClassDB::set_current_api(ClassDB::API_EDITOR); @@ -435,7 +436,6 @@ Error Main::test_setup() { register_platform_apis(); register_module_types(); - register_driver_types(); // Theme needs modules to be initialized so that sub-resources can be loaded. initialize_theme(); @@ -458,13 +458,13 @@ void Main::test_cleanup() { ResourceLoader::remove_custom_loaders(); ResourceSaver::remove_custom_savers(); - unregister_driver_types(); #ifdef TOOLS_ENABLED EditorNode::unregister_editor_types(); #endif unregister_module_types(); unregister_platform_apis(); + unregister_driver_types(); unregister_scene_types(); unregister_server_types(); @@ -1890,6 +1890,10 @@ Error Main::setup2(Thread::ID p_main_tid_override) { register_scene_types(); + MAIN_PRINT("Main: Load Driver Types"); + + register_driver_types(); + #ifdef TOOLS_ENABLED ClassDB::set_current_api(ClassDB::API_EDITOR); EditorNode::register_editor_types(); @@ -1925,14 +1929,12 @@ Error Main::setup2(Thread::ID p_main_tid_override) { camera_server = CameraServer::create(); - MAIN_PRINT("Main: Load Physics, Drivers, Scripts"); + MAIN_PRINT("Main: Load Physics"); initialize_physics(); initialize_navigation_server(); register_server_singletons(); - register_driver_types(); - // This loads global classes, so it must happen before custom loaders and savers are registered ScriptServer::init_languages(); @@ -2816,8 +2818,6 @@ void Main::cleanup(bool p_force) { xr_server->set_primary_interface(Ref()); } - unregister_driver_types(); - #ifdef TOOLS_ENABLED EditorNode::unregister_editor_types(); #endif @@ -2826,6 +2826,7 @@ void Main::cleanup(bool p_force) { unregister_module_types(); unregister_platform_apis(); + unregister_driver_types(); unregister_scene_types(); unregister_server_types();