1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-22 15:06:45 +00:00

Fix editor crash on exit

This commit is contained in:
Fredia Huya-Kouadio
2025-11-08 10:52:57 -08:00
parent 6fd949a6dc
commit 8c469be225
2 changed files with 11 additions and 3 deletions

View File

@@ -35,7 +35,7 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/run/game_view_plugin.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(), nullptr);
ERR_FAIL_NULL_V(EditorNode::get_singleton()->get_editor_main_screen(), nullptr); ERR_FAIL_NULL_V(EditorNode::get_singleton()->get_editor_main_screen(), nullptr);
return Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game")); return Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));

View File

@@ -74,6 +74,14 @@ String _remove_symlink(const String &dir) {
return dir_without_symlink; 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<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
}
#endif
class AndroidLogger : public Logger { class AndroidLogger : public Logger {
public: public:
virtual void logv(const char *p_format, va_list p_list, bool p_err) { 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 #ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(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) { if (game_view_plugin != nullptr) {
game_view_plugin->connect("main_screen_changed", callable_mp_static(&OS_Android::_on_main_screen_changed)); 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() { void OS_Android::main_loop_end() {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(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) { if (game_view_plugin != nullptr) {
game_view_plugin->disconnect("main_screen_changed", callable_mp_static(&OS_Android::_on_main_screen_changed)); game_view_plugin->disconnect("main_screen_changed", callable_mp_static(&OS_Android::_on_main_screen_changed));
} }