From 4067d7d30f84e8027940370d97b4104ad083f6ff Mon Sep 17 00:00:00 2001 From: Kongfa Waroros Date: Tue, 17 Jun 2025 19:45:53 +0700 Subject: [PATCH] Free nodes from instantiating if it is not a Control in the theme editor --- editor/plugins/theme_editor_preview.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index a31b766ef39..b6a3cfd81b9 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -510,8 +510,15 @@ bool SceneThemeEditorPreview::set_preview_scene(const String &p_path) { } Node *instance = loaded_scene->instantiate(); - if (!instance || !Object::cast_to(instance)) { + + if (!instance) { + EditorNode::get_singleton()->show_warning(TTR("Invalid PackedScene resource, could not instantiate it.")); + return false; + } + + if (!Object::cast_to(instance)) { EditorNode::get_singleton()->show_warning(TTR("Invalid PackedScene resource, must have a Control node at its root.")); + memdelete(instance); return false; }