Skip to content

Commit

Permalink
Fix Crash when trying to undo SpriteFrames animation rename godotengi…
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilderin committed Jun 13, 2024
1 parent 475248d commit 4575ccb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions editor/plugins/sprite_frames_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,8 +1476,8 @@ void SpriteFramesEditor::edit(Ref<SpriteFrames> p_frames) {
_fetch_sprite_node(); // Fetch node after set frames.
}

bool SpriteFramesEditor::is_editing() const {
return frames.is_valid();
Ref<SpriteFrames> SpriteFramesEditor::get_sprite_frames() const {
return frames;
}

Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
Expand Down Expand Up @@ -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<SpriteFrames>(p_object);
SpriteFrames *frames = Object::cast_to<SpriteFrames>(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) {
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/sprite_frames_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class SpriteFramesEditor : public HSplitContainer {

public:
void edit(Ref<SpriteFrames> p_frames);
bool is_editing() const;
Ref<SpriteFrames> get_sprite_frames() const;

SpriteFramesEditor();
};
Expand Down

0 comments on commit 4575ccb

Please sign in to comment.