From 9facea9e99bcbc28804b8c448e05030ce3e49418 Mon Sep 17 00:00:00 2001 From: Patrick Dawson Date: Sun, 4 Aug 2024 02:56:39 +0200 Subject: [PATCH] Move in-editor ImGuiController to root node (fix crash on exit) --- gdext/src/ImGuiGD.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gdext/src/ImGuiGD.cpp b/gdext/src/ImGuiGD.cpp index d757a47..1869e53 100644 --- a/gdext/src/ImGuiGD.cpp +++ b/gdext/src/ImGuiGD.cpp @@ -50,11 +50,14 @@ bool ImGuiGD::ToolInit() if (!Engine::get_singleton()->is_editor_hint()) return false; - Node* plugin = Object::cast_to(Engine::get_singleton()->get_singleton("ImGuiPlugin")); + const Node* plugin = Object::cast_to(Engine::get_singleton()->get_singleton("ImGuiPlugin")); ERR_FAIL_COND_V(!plugin, false); - if (!plugin->get_node_or_null("ImGuiController")) + Window* parent = plugin->get_window(); + ERR_FAIL_COND_V(!parent, false); + + if (!parent->get_node_or_null("ImGuiController")) { - plugin->add_child(memnew(ImGuiController)); + parent->add_child(memnew(ImGuiController)); } return true; #else