VSE: Fix crashes adding freeze-frames to segments

If a freeze-frame retiming key was added to either a transition or
freeze-frame segment when the strip was selected, Blender would crash.
The issue is that `SEQ_retiming_add_key` returns `nullptr` if the start
key of the current segment is one of these types, and never bothers to
cancel the operation if this happens.

Instead, it only attempts to get a key at the current frame with
`SEQ_retiming_key_get_by_timeline_frame`. This is redundant, since there
are already checks to see if that key exists in `SEQ_retiming_add_key`.
Remove this code and move up the other `nullptr` check to fix the bug.

Pull Request: https://projects.blender.org/blender/blender/pulls/123981
This commit is contained in:
John Kiril Swenson
2024-07-01 23:25:11 +02:00
committed by Richard Antalik
parent 4c8319a227
commit 8d8a84ffb4

View File

@@ -325,17 +325,14 @@ static bool freeze_frame_add_new_for_seq(const bContext *C,
SeqRetimingKey *key = SEQ_retiming_add_key(scene, seq, timeline_frame);
if (key == nullptr) {
key = SEQ_retiming_key_get_by_timeline_frame(scene, seq, timeline_frame);
BKE_report(op->reports, RPT_WARNING, "Cannot create freeze frame");
return false;
}
if (SEQ_retiming_key_is_transition_start(key)) {
BKE_report(op->reports, RPT_WARNING, "Cannot create key inside of speed transition");
return false;
}
if (key == nullptr) {
BKE_report(op->reports, RPT_WARNING, "Cannot create freeze frame");
return false;
}
SeqRetimingKey *freeze = SEQ_retiming_add_freeze_frame(scene, seq, key, duration);