From 8c469be225b0a12fa50ff12587d90ddf2bba5b48 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Sat, 8 Nov 2025 10:52:57 -0800 Subject: [PATCH] Fix editor crash on exit --- platform/android/editor/game_menu_utils_jni.cpp | 2 +- platform/android/os_android.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/platform/android/editor/game_menu_utils_jni.cpp b/platform/android/editor/game_menu_utils_jni.cpp index 98442b59a41..efdccc8b63b 100644 --- a/platform/android/editor/game_menu_utils_jni.cpp +++ b/platform/android/editor/game_menu_utils_jni.cpp @@ -35,7 +35,7 @@ #include "editor/editor_node.h" #include "editor/run/game_view_plugin.h" -static GameViewPlugin *_get_game_view_plugin() { +_FORCE_INLINE_ static GameViewPlugin *_get_game_view_plugin() { ERR_FAIL_NULL_V(EditorNode::get_singleton(), nullptr); ERR_FAIL_NULL_V(EditorNode::get_singleton()->get_editor_main_screen(), nullptr); return Object::cast_to(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game")); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 5b8e2b23e28..9a351708867 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -74,6 +74,14 @@ String _remove_symlink(const String &dir) { return dir_without_symlink; } +#ifdef TOOLS_ENABLED +_FORCE_INLINE_ static GameViewPlugin *_get_game_view_plugin() { + ERR_FAIL_NULL_V(EditorNode::get_singleton(), nullptr); + ERR_FAIL_NULL_V(EditorNode::get_singleton()->get_editor_main_screen(), nullptr); + return Object::cast_to(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game")); +} +#endif + class AndroidLogger : public Logger { public: virtual void logv(const char *p_format, va_list p_list, bool p_err) { @@ -347,7 +355,7 @@ void OS_Android::main_loop_begin() { #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint()) { - GameViewPlugin *game_view_plugin = Object::cast_to(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game")); + GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr) { game_view_plugin->connect("main_screen_changed", callable_mp_static(&OS_Android::_on_main_screen_changed)); } @@ -377,7 +385,7 @@ bool OS_Android::main_loop_iterate(bool *r_should_swap_buffers) { void OS_Android::main_loop_end() { #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint()) { - GameViewPlugin *game_view_plugin = Object::cast_to(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game")); + GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr) { game_view_plugin->disconnect("main_screen_changed", callable_mp_static(&OS_Android::_on_main_screen_changed)); }