Reorder native extension types initialization, initializing editor last

This commit is contained in:
Gilles Roudière 2022-02-28 14:50:43 +01:00
parent 345b4bb86a
commit ce512b35c1
5 changed files with 14 additions and 10 deletions

View file

@ -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;

View file

@ -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);
}

View file

@ -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;

View file

@ -43,7 +43,9 @@
</constant>
<constant name="INITIALIZATION_LEVEL_SCENE" value="2" enum="InitializationLevel">
</constant>
<constant name="INITIALIZATION_LEVEL_EDITOR" value="3" enum="InitializationLevel">
<constant name="INITIALIZATION_LEVEL_DRIVER" value="3" enum="InitializationLevel">
</constant>
<constant name="INITIALIZATION_LEVEL_EDITOR" value="4" enum="InitializationLevel">
</constant>
</constants>
</class>

View file

@ -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<XRInterface>());
}
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();