소스 검색

Merge pull request #93112 from Hilderin/fix-crash-undo-spriteframes-rename

Fix Crash when trying to undo SpriteFrames animation rename #93079
Rémi Verschelde 1 년 전
부모
커밋
93447ceb37
2개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 3
      editor/plugins/sprite_frames_editor_plugin.cpp
  2. 1 1
      editor/plugins/sprite_frames_editor_plugin.h

+ 7 - 3
editor/plugins/sprite_frames_editor_plugin.cpp

@@ -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) {
@@ -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) {

+ 1 - 1
editor/plugins/sprite_frames_editor_plugin.h

@@ -269,7 +269,7 @@ protected:
 
 public:
 	void edit(Ref<SpriteFrames> p_frames);
-	bool is_editing() const;
+	Ref<SpriteFrames> get_sprite_frames() const;
 
 	SpriteFramesEditor();
 };