Skip to content

Commit 393465c

Browse files
committed
Register editor classes normally, rather than via ClassDB::set_current_api()
1 parent 701505e commit 393465c

File tree

6 files changed

+30
-65
lines changed

6 files changed

+30
-65
lines changed

modules/fbx/register_types.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,13 @@ void initialize_fbx_module(ModuleInitializationLevel p_level) {
6161

6262
#ifdef TOOLS_ENABLED
6363
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
64-
// Editor-specific API.
65-
ClassDB::APIType prev_api = ClassDB::get_current_api();
66-
ClassDB::set_current_api(ClassDB::API_EDITOR);
67-
6864
GDREGISTER_CLASS(EditorSceneFormatImporterUFBX);
6965

7066
GLOBAL_DEF_RST_BASIC("filesystem/import/fbx2gltf/enabled", true);
7167
GDREGISTER_CLASS(EditorSceneFormatImporterFBX2GLTF);
7268
GLOBAL_DEF_RST("filesystem/import/fbx2gltf/enabled.android", false);
7369
GLOBAL_DEF_RST("filesystem/import/fbx2gltf/enabled.web", false);
7470

75-
ClassDB::set_current_api(prev_api);
7671
EditorNode::add_init_callback(_editor_init);
7772
}
7873
#endif // TOOLS_ENABLED

modules/gdscript/register_types.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,7 @@ void initialize_gdscript_module(ModuleInitializationLevel p_level) {
162162
gdscript_translation_parser_plugin.instantiate();
163163
EditorTranslationParser::get_singleton()->add_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD);
164164
} else if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
165-
ClassDB::APIType prev_api = ClassDB::get_current_api();
166-
ClassDB::set_current_api(ClassDB::API_EDITOR);
167-
168165
GDREGISTER_CLASS(GDScriptSyntaxHighlighter);
169-
170-
ClassDB::set_current_api(prev_api);
171166
}
172167
#endif // TOOLS_ENABLED
173168
}

modules/gltf/register_types.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
135135

136136
#ifdef TOOLS_ENABLED
137137
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
138-
// Editor-specific API.
139-
ClassDB::APIType prev_api = ClassDB::get_current_api();
140-
ClassDB::set_current_api(ClassDB::API_EDITOR);
141-
142138
GDREGISTER_CLASS(EditorSceneFormatImporterGLTF);
143139
EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
144140

@@ -149,10 +145,8 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
149145
GLOBAL_DEF_RST("filesystem/import/blender/enabled.android", false);
150146
GLOBAL_DEF_RST("filesystem/import/blender/enabled.web", false);
151147

152-
ClassDB::set_current_api(prev_api);
153148
EditorNode::add_init_callback(_editor_init);
154149
}
155-
156150
#endif // TOOLS_ENABLED
157151
}
158152

modules/minimp3/register_types.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,30 @@
3333
#include "audio_stream_mp3.h"
3434

3535
#ifdef TOOLS_ENABLED
36+
#include "core/config/engine.h"
37+
#include "editor/editor_node.h"
3638
#include "resource_importer_mp3.h"
37-
#endif
3839

39-
#ifdef TOOLS_ENABLED
40-
#include "core/config/engine.h"
40+
static void _editor_init() {
41+
Ref<ResourceImporterMP3> mp3_import;
42+
mp3_import.instantiate();
43+
ResourceFormatImporter::get_singleton()->add_importer(mp3_import);
44+
}
4145
#endif
4246

4347
void initialize_minimp3_module(ModuleInitializationLevel p_level) {
44-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
45-
return;
48+
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
49+
GDREGISTER_CLASS(AudioStreamMP3);
4650
}
4751

4852
#ifdef TOOLS_ENABLED
49-
if (Engine::get_singleton()->is_editor_hint()) {
50-
Ref<ResourceImporterMP3> mp3_import;
51-
mp3_import.instantiate();
52-
ResourceFormatImporter::get_singleton()->add_importer(mp3_import);
53-
}
53+
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
54+
GDREGISTER_CLASS(ResourceImporterMP3);
5455

55-
ClassDB::APIType prev_api = ClassDB::get_current_api();
56-
ClassDB::set_current_api(ClassDB::API_EDITOR);
57-
58-
// Required to document import options in the class reference.
59-
GDREGISTER_CLASS(ResourceImporterMP3);
60-
61-
ClassDB::set_current_api(prev_api);
56+
EditorNode::add_init_callback(_editor_init);
57+
}
6258
#endif
63-
64-
GDREGISTER_CLASS(AudioStreamMP3);
6559
}
6660

6761
void uninitialize_minimp3_module(ModuleInitializationLevel p_level) {
68-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
69-
return;
70-
}
7162
}

modules/openxr/register_types.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,17 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) {
225225
openxr_interface->initialize();
226226
}
227227
}
228+
}
228229

229230
#ifdef TOOLS_ENABLED
230-
// Register as "editor", not "core".
231-
ClassDB::APIType prev_api = ClassDB::get_current_api();
232-
ClassDB::set_current_api(ClassDB::API_EDITOR);
233-
231+
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
234232
GDREGISTER_ABSTRACT_CLASS(OpenXRInteractionProfileEditorBase);
235233
GDREGISTER_CLASS(OpenXRInteractionProfileEditor);
236234
GDREGISTER_CLASS(OpenXRBindingModifierEditor);
237235

238-
ClassDB::set_current_api(prev_api);
239-
240236
EditorNode::add_init_callback(_editor_init);
241-
#endif
242237
}
238+
#endif
243239
}
244240

245241
void uninitialize_openxr_module(ModuleInitializationLevel p_level) {

modules/vorbis/register_types.cpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,30 @@
3333
#include "audio_stream_ogg_vorbis.h"
3434

3535
#ifdef TOOLS_ENABLED
36+
#include "editor/editor_node.h"
3637
#include "resource_importer_ogg_vorbis.h"
38+
39+
static void _editor_init() {
40+
Ref<ResourceImporterOggVorbis> ogg_vorbis_importer;
41+
ogg_vorbis_importer.instantiate();
42+
ResourceFormatImporter::get_singleton()->add_importer(ogg_vorbis_importer);
43+
}
3744
#endif
3845

3946
void initialize_vorbis_module(ModuleInitializationLevel p_level) {
40-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
41-
return;
47+
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
48+
GDREGISTER_CLASS(AudioStreamOggVorbis);
49+
GDREGISTER_CLASS(AudioStreamPlaybackOggVorbis);
4250
}
4351

4452
#ifdef TOOLS_ENABLED
45-
if (Engine::get_singleton()->is_editor_hint()) {
46-
Ref<ResourceImporterOggVorbis> ogg_vorbis_importer;
47-
ogg_vorbis_importer.instantiate();
48-
ResourceFormatImporter::get_singleton()->add_importer(ogg_vorbis_importer);
49-
}
50-
51-
ClassDB::APIType prev_api = ClassDB::get_current_api();
52-
ClassDB::set_current_api(ClassDB::API_EDITOR);
53+
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
54+
GDREGISTER_CLASS(ResourceImporterOggVorbis);
5355

54-
// Required to document import options in the class reference.
55-
GDREGISTER_CLASS(ResourceImporterOggVorbis);
56-
57-
ClassDB::set_current_api(prev_api);
56+
EditorNode::add_init_callback(_editor_init);
57+
}
5858
#endif
59-
60-
GDREGISTER_CLASS(AudioStreamOggVorbis);
61-
GDREGISTER_CLASS(AudioStreamPlaybackOggVorbis);
6259
}
6360

6461
void uninitialize_vorbis_module(ModuleInitializationLevel p_level) {
65-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
66-
return;
67-
}
6862
}

0 commit comments

Comments
 (0)