Skip to content

Commit 4067d7d

Browse files
committed
Free nodes from instantiating if it is not a Control in the theme editor
1 parent 46c495c commit 4067d7d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

editor/plugins/theme_editor_preview.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,15 @@ bool SceneThemeEditorPreview::set_preview_scene(const String &p_path) {
510510
}
511511

512512
Node *instance = loaded_scene->instantiate();
513-
if (!instance || !Object::cast_to<Control>(instance)) {
513+
514+
if (!instance) {
515+
EditorNode::get_singleton()->show_warning(TTR("Invalid PackedScene resource, could not instantiate it."));
516+
return false;
517+
}
518+
519+
if (!Object::cast_to<Control>(instance)) {
514520
EditorNode::get_singleton()->show_warning(TTR("Invalid PackedScene resource, must have a Control node at its root."));
521+
memdelete(instance);
515522
return false;
516523
}
517524

0 commit comments

Comments
 (0)