From f20e5152adc548bc7e662b52f00b0ee4a2adc2e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?=
<7645683+bruvzg@users.noreply.github.com>
Date: Wed, 16 Jul 2025 08:55:23 +0300
Subject: [PATCH] [EditorExportPlatform] Move initialization to a dedicated
method.
---
doc/classes/EditorExportPlatformExtension.xml | 6 +++++
editor/export/editor_export.cpp | 1 +
editor/export/editor_export_platform.h | 2 ++
.../editor_export_platform_apple_embedded.cpp | 22 +++++++++----------
.../editor_export_platform_apple_embedded.h | 3 ++-
.../editor_export_platform_extension.cpp | 6 +++++
.../export/editor_export_platform_extension.h | 3 +++
platform/android/export/export_plugin.cpp | 2 +-
platform/android/export/export_plugin.h | 2 +-
platform/ios/export/export_plugin.cpp | 10 ++++++---
platform/ios/export/export_plugin.h | 2 +-
platform/linuxbsd/export/export_plugin.cpp | 2 +-
platform/linuxbsd/export/export_plugin.h | 2 +-
platform/macos/export/export_plugin.cpp | 2 +-
platform/macos/export/export_plugin.h | 2 +-
platform/visionos/export/export_plugin.cpp | 10 ++++++---
platform/visionos/export/export_plugin.h | 2 +-
platform/web/export/export_plugin.cpp | 2 +-
platform/web/export/export_plugin.h | 2 +-
platform/windows/export/export_plugin.cpp | 2 +-
platform/windows/export/export_plugin.h | 2 +-
21 files changed, 56 insertions(+), 31 deletions(-)
diff --git a/doc/classes/EditorExportPlatformExtension.xml b/doc/classes/EditorExportPlatformExtension.xml
index 5ed35711614..1a90397e03d 100644
--- a/doc/classes/EditorExportPlatformExtension.xml
+++ b/doc/classes/EditorExportPlatformExtension.xml
@@ -221,6 +221,12 @@
Returns [code]true[/code] if project configuration is valid.
+
+
+
+ Initializes the plugin. Called by the editor when platform is registered.
+
+
diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp
index 5e76c5950a3..e28304c4fca 100644
--- a/editor/export/editor_export.cpp
+++ b/editor/export/editor_export.cpp
@@ -127,6 +127,7 @@ void EditorExport::_bind_methods() {
}
void EditorExport::add_export_platform(const Ref &p_platform) {
+ p_platform->initialize();
export_platforms.push_back(p_platform);
should_update_presets = true;
diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h
index 8c3488ab05a..1c3fb7dbaf6 100644
--- a/editor/export/editor_export_platform.h
+++ b/editor/export/editor_export_platform.h
@@ -349,6 +349,8 @@ public:
virtual void resolve_platform_feature_priorities(const Ref &p_preset, HashSet &p_features) {}
virtual String get_debug_protocol() const { return "tcp://"; }
virtual HashMap get_custom_project_settings(const Ref &p_preset) const { return HashMap(); }
+
+ virtual void initialize() {}
};
VARIANT_ENUM_CAST(EditorExportPlatform::ExportMessageType)
diff --git a/editor/export/editor_export_platform_apple_embedded.cpp b/editor/export/editor_export_platform_apple_embedded.cpp
index b870544b450..71ba12e18cd 100644
--- a/editor/export/editor_export_platform_apple_embedded.cpp
+++ b/editor/export/editor_export_platform_apple_embedded.cpp
@@ -2873,23 +2873,21 @@ Error EditorExportPlatformAppleEmbedded::run(const Ref &p_pr
#endif
}
-EditorExportPlatformAppleEmbedded::EditorExportPlatformAppleEmbedded(const char *p_platform_logo_svg, const char *p_run_icon_svg) {
- if (EditorNode::get_singleton()) {
- Ref img = memnew(Image);
- const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
+void EditorExportPlatformAppleEmbedded::_initialize(const char *p_platform_logo_svg, const char *p_run_icon_svg) {
+ Ref img = memnew(Image);
+ const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
- ImageLoaderSVG::create_image_from_string(img, p_platform_logo_svg, EDSCALE, upsample, false);
- logo = ImageTexture::create_from_image(img);
+ ImageLoaderSVG::create_image_from_string(img, p_platform_logo_svg, EDSCALE, upsample, false);
+ logo = ImageTexture::create_from_image(img);
- ImageLoaderSVG::create_image_from_string(img, p_run_icon_svg, EDSCALE, upsample, false);
- run_icon = ImageTexture::create_from_image(img);
+ ImageLoaderSVG::create_image_from_string(img, p_run_icon_svg, EDSCALE, upsample, false);
+ run_icon = ImageTexture::create_from_image(img);
- plugins_changed.set();
- devices_changed.set();
+ plugins_changed.set();
+ devices_changed.set();
#ifdef MACOS_ENABLED
- _update_preset_status();
+ _update_preset_status();
#endif
- }
}
EditorExportPlatformAppleEmbedded::~EditorExportPlatformAppleEmbedded() {
diff --git a/editor/export/editor_export_platform_apple_embedded.h b/editor/export/editor_export_platform_apple_embedded.h
index 8673e323ab1..23c30eb32fa 100644
--- a/editor/export/editor_export_platform_apple_embedded.h
+++ b/editor/export/editor_export_platform_apple_embedded.h
@@ -196,6 +196,8 @@ protected:
r_features->push_back("apple_embedded");
}
+ void _initialize(const char *p_platform_logo_svg, const char *p_run_icon_svg);
+
public:
virtual Ref get_logo() const override { return logo; }
virtual Ref get_run_icon() const override { return run_icon; }
@@ -246,7 +248,6 @@ public:
virtual void resolve_platform_feature_priorities(const Ref &p_preset, HashSet &p_features) override {
}
- EditorExportPlatformAppleEmbedded(const char *p_platform_logo_svg, const char *p_run_icon_svg);
~EditorExportPlatformAppleEmbedded();
/// List the gdip files in the directory specified by the p_path parameter.
diff --git a/editor/export/editor_export_platform_extension.cpp b/editor/export/editor_export_platform_extension.cpp
index b4f338437f0..5c789c13799 100644
--- a/editor/export/editor_export_platform_extension.cpp
+++ b/editor/export/editor_export_platform_extension.cpp
@@ -77,6 +77,8 @@ void EditorExportPlatformExtension::_bind_methods() {
GDVIRTUAL_BIND(_get_platform_features);
GDVIRTUAL_BIND(_get_debug_protocol);
+
+ GDVIRTUAL_BIND(_initialize);
}
void EditorExportPlatformExtension::get_preset_features(const Ref &p_preset, List *r_features) const {
@@ -348,6 +350,10 @@ String EditorExportPlatformExtension::get_debug_protocol() const {
return EditorExportPlatform::get_debug_protocol();
}
+void EditorExportPlatformExtension::initialize() {
+ GDVIRTUAL_CALL(_initialize);
+}
+
EditorExportPlatformExtension::EditorExportPlatformExtension() {
//NOP
}
diff --git a/editor/export/editor_export_platform_extension.h b/editor/export/editor_export_platform_extension.h
index 032f466cc43..2633444034a 100644
--- a/editor/export/editor_export_platform_extension.h
+++ b/editor/export/editor_export_platform_extension.h
@@ -147,6 +147,9 @@ public:
virtual String get_debug_protocol() const override;
GDVIRTUAL0RC(String, _get_debug_protocol);
+ virtual void initialize() override;
+ GDVIRTUAL0(_initialize);
+
EditorExportPlatformExtension();
~EditorExportPlatformExtension();
};
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 7d7397c060c..fcbe5cbb082 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -4226,7 +4226,7 @@ void EditorExportPlatformAndroid::get_platform_features(List *r_features
void EditorExportPlatformAndroid::resolve_platform_feature_priorities(const Ref &p_preset, HashSet &p_features) {
}
-EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
+void EditorExportPlatformAndroid::initialize() {
if (EditorNode::get_singleton()) {
Ref img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h
index a17c4374141..8d214531d5d 100644
--- a/platform/android/export/export_plugin.h
+++ b/platform/android/export/export_plugin.h
@@ -279,7 +279,7 @@ public:
virtual void resolve_platform_feature_priorities(const Ref &p_preset, HashSet &p_features) override;
- EditorExportPlatformAndroid();
+ virtual void initialize() override;
~EditorExportPlatformAndroid();
};
diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp
index 1f40fe27dd7..f44613b4163 100644
--- a/platform/ios/export/export_plugin.cpp
+++ b/platform/ios/export/export_plugin.cpp
@@ -33,13 +33,17 @@
#include "logo_svg.gen.h"
#include "run_icon_svg.gen.h"
+#include "editor/editor_node.h"
+
Vector EditorExportPlatformIOS::device_types({ "iPhone", "iPad" });
-EditorExportPlatformIOS::EditorExportPlatformIOS() :
- EditorExportPlatformAppleEmbedded(_ios_logo_svg, _ios_run_icon_svg) {
+void EditorExportPlatformIOS::initialize() {
+ if (EditorNode::get_singleton()) {
+ EditorExportPlatformAppleEmbedded::_initialize(_ios_logo_svg, _ios_run_icon_svg);
#ifdef MACOS_ENABLED
- _start_remote_device_poller_thread();
+ _start_remote_device_poller_thread();
#endif
+ }
}
EditorExportPlatformIOS::~EditorExportPlatformIOS() {
diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h
index f7892df3ec5..24409d662ee 100644
--- a/platform/ios/export/export_plugin.h
+++ b/platform/ios/export/export_plugin.h
@@ -61,6 +61,6 @@ public:
r_features->push_back("ios");
}
- EditorExportPlatformIOS();
+ virtual void initialize() override;
~EditorExportPlatformIOS();
};
diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp
index e184d8d94cd..ed5ca267f09 100644
--- a/platform/linuxbsd/export/export_plugin.cpp
+++ b/platform/linuxbsd/export/export_plugin.cpp
@@ -608,7 +608,7 @@ Error EditorExportPlatformLinuxBSD::run(const Ref &p_preset,
#undef CLEANUP_AND_RETURN
}
-EditorExportPlatformLinuxBSD::EditorExportPlatformLinuxBSD() {
+void EditorExportPlatformLinuxBSD::initialize() {
if (EditorNode::get_singleton()) {
Ref img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
diff --git a/platform/linuxbsd/export/export_plugin.h b/platform/linuxbsd/export/export_plugin.h
index d375ceef618..359c723de04 100644
--- a/platform/linuxbsd/export/export_plugin.h
+++ b/platform/linuxbsd/export/export_plugin.h
@@ -89,5 +89,5 @@ public:
virtual Error run(const Ref &p_preset, int p_device, BitField p_debug_flags) override;
virtual void cleanup() override;
- EditorExportPlatformLinuxBSD();
+ virtual void initialize() override;
};
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index 05bcf6a9c9d..e918221aef2 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -2718,7 +2718,7 @@ Error EditorExportPlatformMacOS::run(const Ref &p_preset, in
#undef CLEANUP_AND_RETURN
}
-EditorExportPlatformMacOS::EditorExportPlatformMacOS() {
+void EditorExportPlatformMacOS::initialize() {
if (EditorNode::get_singleton()) {
Ref img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
diff --git a/platform/macos/export/export_plugin.h b/platform/macos/export/export_plugin.h
index 5084bf02633..ec9ed0eb83b 100644
--- a/platform/macos/export/export_plugin.h
+++ b/platform/macos/export/export_plugin.h
@@ -169,5 +169,5 @@ public:
virtual Error run(const Ref &p_preset, int p_device, BitField p_debug_flags) override;
virtual void cleanup() override;
- EditorExportPlatformMacOS();
+ virtual void initialize() override;
};
diff --git a/platform/visionos/export/export_plugin.cpp b/platform/visionos/export/export_plugin.cpp
index 5f188a3fdb7..717ec4cadf2 100644
--- a/platform/visionos/export/export_plugin.cpp
+++ b/platform/visionos/export/export_plugin.cpp
@@ -33,13 +33,17 @@
#include "logo_svg.gen.h"
#include "run_icon_svg.gen.h"
+#include "editor/editor_node.h"
+
Vector EditorExportPlatformVisionOS::device_types({ "realityDevice" });
-EditorExportPlatformVisionOS::EditorExportPlatformVisionOS() :
- EditorExportPlatformAppleEmbedded(_visionos_logo_svg, _visionos_run_icon_svg) {
+void EditorExportPlatformVisionOS::initialize() {
+ if (EditorNode::get_singleton()) {
+ EditorExportPlatformAppleEmbedded::_initialize(_visionos_logo_svg, _visionos_run_icon_svg);
#ifdef MACOS_ENABLED
- _start_remote_device_poller_thread();
+ _start_remote_device_poller_thread();
#endif
+ }
}
EditorExportPlatformVisionOS::~EditorExportPlatformVisionOS() {
diff --git a/platform/visionos/export/export_plugin.h b/platform/visionos/export/export_plugin.h
index 39e95af4e49..eef3e3a7205 100644
--- a/platform/visionos/export/export_plugin.h
+++ b/platform/visionos/export/export_plugin.h
@@ -56,6 +56,6 @@ public:
r_features->push_back("visionos");
}
- EditorExportPlatformVisionOS();
+ virtual void initialize() override;
~EditorExportPlatformVisionOS();
};
diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp
index 284e17a8817..b454b9e8735 100644
--- a/platform/web/export/export_plugin.cpp
+++ b/platform/web/export/export_plugin.cpp
@@ -916,7 +916,7 @@ Ref EditorExportPlatformWeb::get_run_icon() const {
return run_icon;
}
-EditorExportPlatformWeb::EditorExportPlatformWeb() {
+void EditorExportPlatformWeb::initialize() {
if (EditorNode::get_singleton()) {
server.instantiate();
diff --git a/platform/web/export/export_plugin.h b/platform/web/export/export_plugin.h
index 5e6f6fa8181..80c2f67a5a9 100644
--- a/platform/web/export/export_plugin.h
+++ b/platform/web/export/export_plugin.h
@@ -148,6 +148,6 @@ public:
String get_debug_protocol() const override { return "ws://"; }
- EditorExportPlatformWeb();
+ virtual void initialize() override;
~EditorExportPlatformWeb();
};
diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp
index 3be93663462..f3974c50ba3 100644
--- a/platform/windows/export/export_plugin.cpp
+++ b/platform/windows/export/export_plugin.cpp
@@ -1090,7 +1090,7 @@ Error EditorExportPlatformWindows::run(const Ref &p_preset,
#undef CLEANUP_AND_RETURN
}
-EditorExportPlatformWindows::EditorExportPlatformWindows() {
+void EditorExportPlatformWindows::initialize() {
if (EditorNode::get_singleton()) {
Ref img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
diff --git a/platform/windows/export/export_plugin.h b/platform/windows/export/export_plugin.h
index 034f58d8706..98bdd87ec6f 100644
--- a/platform/windows/export/export_plugin.h
+++ b/platform/windows/export/export_plugin.h
@@ -97,5 +97,5 @@ public:
virtual Error run(const Ref &p_preset, int p_device, BitField p_debug_flags) override;
virtual void cleanup() override;
- EditorExportPlatformWindows();
+ virtual void initialize() override;
};