Browse Source

Merge pull request #44865 from RandomShaper/fix_reset_anim_crash

Fix crash related to reset animation
Rémi Verschelde 4 years ago
parent
commit
c0846b62b0
2 changed files with 6 additions and 6 deletions
  1. 5 5
      editor/animation_track_editor.cpp
  2. 1 1
      editor/animation_track_editor.h

+ 5 - 5
editor/animation_track_editor.cpp

@@ -3431,7 +3431,7 @@ void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_bezi
 		if (insert_data.front()->get().advance) {
 		if (insert_data.front()->get().advance) {
 			advance = true;
 			advance = true;
 		}
 		}
-		next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, p_create_reset, p_create_beziers);
+		next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, p_create_reset, reset_anim, p_create_beziers);
 		insert_data.pop_front();
 		insert_data.pop_front();
 	}
 	}
 
 
@@ -3749,7 +3749,7 @@ void AnimationTrackEditor::_confirm_insert_list() {
 
 
 	TrackIndices next_tracks(animation.ptr(), reset_anim.ptr());
 	TrackIndices next_tracks(animation.ptr(), reset_anim.ptr());
 	while (insert_data.size()) {
 	while (insert_data.size()) {
-		next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, create_reset, insert_confirm_bezier->is_pressed());
+		next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, create_reset, reset_anim, insert_confirm_bezier->is_pressed());
 		insert_data.pop_front();
 		insert_data.pop_front();
 	}
 	}
 
 
@@ -3869,7 +3869,7 @@ static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool
 	return subindices;
 	return subindices;
 }
 }
 
 
-AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, bool p_create_beziers) {
+AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, Ref<Animation> p_reset_anim, bool p_create_beziers) {
 	bool created = false;
 	bool created = false;
 	if (p_id.track_idx < 0) {
 	if (p_id.track_idx < 0) {
 		if (p_create_beziers) {
 		if (p_create_beziers) {
@@ -3881,7 +3881,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
 					id.type = Animation::TYPE_BEZIER;
 					id.type = Animation::TYPE_BEZIER;
 					id.value = p_id.value.get(subindices[i].substr(1, subindices[i].length()));
 					id.value = p_id.value.get(subindices[i].substr(1, subindices[i].length()));
 					id.path = String(p_id.path) + subindices[i];
 					id.path = String(p_id.path) + subindices[i];
-					p_next_tracks = _confirm_insert(id, p_next_tracks, p_create_reset, false);
+					p_next_tracks = _confirm_insert(id, p_next_tracks, p_create_reset, p_reset_anim, false);
 				}
 				}
 
 
 				return p_next_tracks;
 				return p_next_tracks;
@@ -3986,7 +3986,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
 
 
 	if (p_create_reset && track_type_is_resettable(p_id.type)) {
 	if (p_create_reset && track_type_is_resettable(p_id.type)) {
 		bool create_reset_track = true;
 		bool create_reset_track = true;
-		Animation *reset_anim = AnimationPlayerEditor::singleton->get_player()->get_animation("RESET").ptr();
+		Animation *reset_anim = p_reset_anim.ptr();
 		for (int i = 0; i < reset_anim->get_track_count(); i++) {
 		for (int i = 0; i < reset_anim->get_track_count(); i++) {
 			if (reset_anim->track_get_path(i) == p_id.path) {
 			if (reset_anim->track_get_path(i) == p_id.path) {
 				create_reset_track = false;
 				create_reset_track = false;

+ 1 - 1
editor/animation_track_editor.h

@@ -384,7 +384,7 @@ class AnimationTrackEditor : public VBoxContainer {
 			reset = p_reset_anim ? p_reset_anim->get_track_count() : 0;
 			reset = p_reset_anim ? p_reset_anim->get_track_count() : 0;
 		}
 		}
 	};
 	};
-	TrackIndices _confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, bool p_create_beziers);
+	TrackIndices _confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, Ref<Animation> p_reset_anim, bool p_create_beziers);
 	void _insert_delay(bool p_create_reset, bool p_create_beziers);
 	void _insert_delay(bool p_create_reset, bool p_create_beziers);
 
 
 	void _root_removed(Node *p_root);
 	void _root_removed(Node *p_root);