Skip to content

Commit 6ece887

Browse files
m4gr3dnontoxicguy
and
nontoxicguy
authored
Code cleanup for the export logic (#118)
Update the export logic so that export plugin objects are handed through references instead of using `memnew` and `memfree` (cherry picked from commit e946c3a) Co-authored-by: nontoxicguy <[email protected]>
1 parent 595cd64 commit 6ece887

File tree

9 files changed

+13
-17
lines changed

9 files changed

+13
-17
lines changed

Diff for: CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change history for the Godot OpenXR loaders asset
22

33
## 2.0.4
4+
- Fix misc crash when reloading project on Godot 4.3
45
- Fix issue with only the first permission being requested
56

67
## 2.0.3

Diff for: godotopenxrkhronos/src/main/cpp/export/khronos_export_plugin.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@ void KhronosEditorPlugin::_bind_methods() {}
3535

3636
void KhronosEditorPlugin::_enter_tree() {
3737
// Initialize the editor export plugin
38-
khronos_export_plugin = memnew(KhronosEditorExportPlugin);
38+
khronos_export_plugin.instantiate();
3939
add_export_plugin(khronos_export_plugin);
4040
}
4141

4242
void KhronosEditorPlugin::_exit_tree() {
4343
// Clean up the editor export plugin
4444
remove_export_plugin(khronos_export_plugin);
4545

46-
memfree(khronos_export_plugin);
47-
khronos_export_plugin = nullptr;
46+
khronos_export_plugin.unref();
4847
}
4948

5049
KhronosEditorExportPlugin::KhronosEditorExportPlugin() {

Diff for: godotopenxrkhronos/src/main/cpp/export/khronos_export_plugin.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ class KhronosEditorPlugin : public EditorPlugin {
5858
static void _bind_methods();
5959

6060
private:
61-
KhronosEditorExportPlugin *khronos_export_plugin = nullptr;
61+
Ref<KhronosEditorExportPlugin> khronos_export_plugin;
6262
};

Diff for: godotopenxrlynx/src/main/cpp/export/lynx_export_plugin.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void LynxEditorPlugin::_bind_methods() {}
3535

3636
void LynxEditorPlugin::_enter_tree() {
3737
// Initialize the editor export plugin
38-
lynx_export_plugin = memnew(OpenXREditorExportPlugin);
38+
lynx_export_plugin.instantiate();
3939
lynx_export_plugin->set_vendor_name(LYNX_VENDOR_NAME);
4040
add_export_plugin(lynx_export_plugin);
4141
}
@@ -44,6 +44,5 @@ void LynxEditorPlugin::_exit_tree() {
4444
// Clean up the editor export plugin
4545
remove_export_plugin(lynx_export_plugin);
4646

47-
memfree(lynx_export_plugin);
48-
lynx_export_plugin = nullptr;
47+
lynx_export_plugin.unref();
4948
}

Diff for: godotopenxrlynx/src/main/cpp/export/lynx_export_plugin.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ class LynxEditorPlugin : public EditorPlugin {
4646
static void _bind_methods();
4747

4848
private:
49-
OpenXREditorExportPlugin *lynx_export_plugin = nullptr;
49+
Ref<OpenXREditorExportPlugin> lynx_export_plugin;
5050
};

Diff for: godotopenxrmeta/src/main/cpp/export/meta_export_plugin.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ void MetaEditorPlugin::_bind_methods() {}
3737

3838
void MetaEditorPlugin::_enter_tree() {
3939
// Initialize the editor export plugin
40-
meta_export_plugin = memnew(MetaEditorExportPlugin);
40+
meta_export_plugin.instantiate();
4141
add_export_plugin(meta_export_plugin);
4242
}
4343

4444
void MetaEditorPlugin::_exit_tree() {
4545
// Clean up the editor export plugin
4646
remove_export_plugin(meta_export_plugin);
4747

48-
memfree(meta_export_plugin);
49-
meta_export_plugin = nullptr;
48+
meta_export_plugin.unref();
5049
}
5150

5251
MetaEditorExportPlugin::MetaEditorExportPlugin() {

Diff for: godotopenxrmeta/src/main/cpp/export/meta_export_plugin.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,5 @@ class MetaEditorPlugin : public EditorPlugin {
101101
static void _bind_methods();
102102

103103
private:
104-
MetaEditorExportPlugin *meta_export_plugin = nullptr;
105-
104+
Ref<MetaEditorExportPlugin> meta_export_plugin;
106105
};

Diff for: godotopenxrpico/src/main/cpp/export/pico_export_plugin.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void PicoEditorPlugin::_bind_methods() {}
3535

3636
void PicoEditorPlugin::_enter_tree() {
3737
// Initialize the editor export plugin
38-
pico_export_plugin = memnew(OpenXREditorExportPlugin);
38+
pico_export_plugin.instantiate();
3939
pico_export_plugin->set_vendor_name(PICO_VENDOR_NAME);
4040
add_export_plugin(pico_export_plugin);
4141
}
@@ -44,6 +44,5 @@ void PicoEditorPlugin::_exit_tree() {
4444
// Clean up the editor export plugin
4545
remove_export_plugin(pico_export_plugin);
4646

47-
memfree(pico_export_plugin);
48-
pico_export_plugin = nullptr;
47+
pico_export_plugin.unref();
4948
}

Diff for: godotopenxrpico/src/main/cpp/export/pico_export_plugin.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ class PicoEditorPlugin : public EditorPlugin {
4646
static void _bind_methods();
4747

4848
private:
49-
OpenXREditorExportPlugin *pico_export_plugin = nullptr;
49+
Ref<OpenXREditorExportPlugin> pico_export_plugin;
5050
};

0 commit comments

Comments
 (0)