From 0069131546b2a00bf4dbbbff1b8e39bbf5d55462 Mon Sep 17 00:00:00 2001 From: Silc Renew Date: Mon, 6 Feb 2023 14:08:12 +0900 Subject: [PATCH] Fix ghost SpriteFramesEditor cause crash --- .../plugins/sprite_frames_editor_plugin.cpp | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 14b5f7cefbb..c41bf4b8ccd 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -1171,32 +1171,29 @@ void SpriteFramesEditor::edit(Ref p_frames) { if (!p_frames.is_valid()) { frames.unref(); + hide(); return; } frames = p_frames; read_only = EditorNode::get_singleton()->is_resource_read_only(p_frames); - if (p_frames.is_valid()) { - if (!p_frames->has_animation(edited_anim)) { - List anim_names; - frames->get_animation_list(&anim_names); - anim_names.sort_custom(); - if (anim_names.size()) { - edited_anim = anim_names.front()->get(); - } else { - edited_anim = StringName(); - } + if (!p_frames->has_animation(edited_anim)) { + List anim_names; + frames->get_animation_list(&anim_names); + anim_names.sort_custom(); + if (anim_names.size()) { + edited_anim = anim_names.front()->get(); + } else { + edited_anim = StringName(); } - - _update_library(); - // Clear zoom and split sheet texture - split_sheet_preview->set_texture(Ref()); - _zoom_reset(); - } else { - hide(); } + _update_library(); + // Clear zoom and split sheet texture + split_sheet_preview->set_texture(Ref()); + _zoom_reset(); + add_anim->set_disabled(read_only); delete_anim->set_disabled(read_only); anim_speed->set_editable(!read_only);