From 4575ccbad959c2678b75411254f89bb162f8095b Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:42:49 -0400 Subject: [PATCH] Fix Crash when trying to undo SpriteFrames animation rename #93079 --- editor/plugins/sprite_frames_editor_plugin.cpp | 10 +++++++--- editor/plugins/sprite_frames_editor_plugin.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index ae6ec0f702..d1da61e5fc 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -1476,8 +1476,8 @@ void SpriteFramesEditor::edit(Ref p_frames) { _fetch_sprite_node(); // Fetch node after set frames. } -bool SpriteFramesEditor::is_editing() const { - return frames.is_valid(); +Ref SpriteFramesEditor::get_sprite_frames() const { + return frames; } Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { @@ -2337,7 +2337,11 @@ bool SpriteFramesEditorPlugin::handles(Object *p_object) const { if (animated_sprite_3d && *animated_sprite_3d->get_sprite_frames()) { return true; } - return !frames_editor->is_editing() && Object::cast_to(p_object); + SpriteFrames *frames = Object::cast_to(p_object); + if (frames && (frames_editor->get_sprite_frames().is_null() || frames_editor->get_sprite_frames() == frames)) { + return true; + } + return false; } void SpriteFramesEditorPlugin::make_visible(bool p_visible) { diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 0e26a793a7..9b6aaf98fe 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -269,7 +269,7 @@ protected: public: void edit(Ref p_frames); - bool is_editing() const; + Ref get_sprite_frames() const; SpriteFramesEditor(); };