Fix #110161: Crash on dragging a Speaker NLA strip

`NLASTRIP_TYPE_TRANSITION` was being used incorrectly as a flag, having
`NLASTRIP_TYPE_TRANSITION=1` and `NLASTRIP_TYPE_SOUND=3` in the enum
`eNlaStrip_Type`, when evaluating `NLASTRIP_TYPE_SOUND &
NLASTRIP_TYPE_TRANSITION` gives a invalid truish value.

Also `strips` that can't be placed were freed, but no removed from the
`strips list`, this will cause a error if the `strip` is at begin
or end of the list.

Pull Request: https://projects.blender.org/blender/blender/pulls/110605
This commit is contained in:
Guillermo
2023-08-03 14:19:49 +02:00
committed by Sybren A. Stüvel
parent c4631644ee
commit 5b3398a673
2 changed files with 7 additions and 7 deletions

View File

@@ -1364,7 +1364,7 @@ NlaStrip *BKE_nlastrip_next_in_track(NlaStrip *strip, bool skip_transitions)
{
NlaStrip *next = strip->next;
while (next != nullptr) {
if (skip_transitions && (next->type & NLASTRIP_TYPE_TRANSITION)) {
if (skip_transitions && (next->type == NLASTRIP_TYPE_TRANSITION)) {
next = next->next;
}
else {
@@ -1378,7 +1378,7 @@ NlaStrip *BKE_nlastrip_prev_in_track(NlaStrip *strip, bool skip_transitions)
{
NlaStrip *prev = strip->prev;
while (prev != nullptr) {
if (skip_transitions && (prev->type & NLASTRIP_TYPE_TRANSITION)) {
if (skip_transitions && (prev->type == NLASTRIP_TYPE_TRANSITION)) {
prev = prev->prev;
}
else {
@@ -1963,10 +1963,10 @@ static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls)
* Strip will be removed / freed if it doesn't fit (invalid).
* Return value indicates if passed strip is valid/fixed or invalid/removed.
*/
static bool nlastrip_validate_transition_start_end(NlaStrip *strip)
static bool nlastrip_validate_transition_start_end(ListBase *strips, NlaStrip *strip)
{
if (!(strip->type & NLASTRIP_TYPE_TRANSITION)) {
if (!(strip->type == NLASTRIP_TYPE_TRANSITION)) {
return true;
}
if (strip->prev) {
@@ -1976,7 +1976,7 @@ static bool nlastrip_validate_transition_start_end(NlaStrip *strip)
strip->end = strip->next->start;
}
if (strip->start >= strip->end || strip->prev == nullptr || strip->next == nullptr) {
BKE_nlastrip_free(strip, true);
BKE_nlastrip_remove_and_free(strips, strip, true);
return false;
}
return true;
@@ -1996,7 +1996,7 @@ void BKE_nla_validate_state(AnimData *adt)
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH_MUTABLE (NlaStrip *, strip, &nlt->strips) {
if (!nlastrip_validate_transition_start_end(strip)) {
if (!nlastrip_validate_transition_start_end(&nlt->strips, strip)) {
printf(
"While moving NLA strips, a transition strip could no longer be applied to the new "
"positions and was removed.\n");

View File

@@ -111,7 +111,7 @@ static float transdata_get_time_shuffle_offset_side(ListBase *trans_datas, const
}
/* Allow overlap with transitions. */
if (non_xformed_strip->type & NLASTRIP_TYPE_TRANSITION) {
if (non_xformed_strip->type == NLASTRIP_TYPE_TRANSITION) {
continue;
}