forked from blender/blender
WIP: uv-simple-select #1
@ -41,10 +41,10 @@ struct PropertyRNA;
|
||||
*/
|
||||
void BKE_nlastrip_free(struct NlaStrip *strip, bool do_id_user);
|
||||
/**
|
||||
* Remove the given NLA track from the set of NLA tracks, free the track's data,
|
||||
* and the track itself.
|
||||
* Remove & Frees all NLA strips from the given NLA track,
|
||||
* then frees (doesn't remove) the track itself.
|
||||
*/
|
||||
void BKE_nlatrack_free(ListBase *tracks, struct NlaTrack *nlt, bool do_id_user);
|
||||
void BKE_nlatrack_free(struct NlaTrack *nlt, bool do_id_user);
|
||||
/**
|
||||
* Free the elements of type NLA Tracks provided in the given list, but do not free
|
||||
* the list itself since that is not free-standing
|
||||
@ -95,6 +95,17 @@ struct NlaTrack *BKE_nlatrack_add(struct AnimData *adt,
|
||||
struct NlaTrack *prev,
|
||||
bool is_liboverride);
|
||||
|
||||
/**
|
||||
* Removes the given NLA track from the list of tracks provided.
|
||||
*/
|
||||
void BKE_nlatrack_remove(ListBase *tracks, struct NlaTrack *nlt);
|
||||
|
||||
/**
|
||||
* Remove the given NLA track from the list of NLA tracks, free the track's data,
|
||||
* and the track itself.
|
||||
*/
|
||||
void BKE_nlatrack_remove_and_free(ListBase *tracks, struct NlaTrack *nlt, bool do_id_user);
|
||||
|
||||
/**
|
||||
* Create a NLA Strip referencing the given Action.
|
||||
*/
|
||||
|
@ -91,7 +91,7 @@ void BKE_nlastrip_free(NlaStrip *strip, const bool do_id_user)
|
||||
MEM_freeN(strip);
|
||||
}
|
||||
|
||||
void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
|
||||
void BKE_nlatrack_free(NlaTrack *nlt, const bool do_id_user)
|
||||
{
|
||||
NlaStrip *strip, *stripn;
|
||||
|
||||
@ -107,13 +107,8 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
|
||||
}
|
||||
|
||||
/* free NLA track itself now */
|
||||
if (tracks) {
|
||||
BLI_freelinkN(tracks, nlt);
|
||||
}
|
||||
else {
|
||||
MEM_freeN(nlt);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
|
||||
{
|
||||
@ -127,7 +122,7 @@ void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
|
||||
/* free tracks one by one */
|
||||
for (nlt = tracks->first; nlt; nlt = nltn) {
|
||||
nltn = nlt->next;
|
||||
BKE_nlatrack_free(tracks, nlt, do_id_user);
|
||||
BKE_nlatrack_remove_and_free(tracks, nlt, do_id_user);
|
||||
}
|
||||
|
||||
/* clear the list's pointers to be safe */
|
||||
@ -514,6 +509,20 @@ void BKE_nla_strip_foreach_id(NlaStrip *strip, LibraryForeachIDData *data)
|
||||
}
|
||||
}
|
||||
|
||||
/* Removing ------------------------------------------ */
|
||||
|
||||
void BKE_nlatrack_remove(ListBase *tracks, struct NlaTrack *nlt)
|
||||
{
|
||||
BLI_assert(tracks);
|
||||
BLI_remlink(tracks, nlt);
|
||||
}
|
||||
|
||||
void BKE_nlatrack_remove_and_free(ListBase *tracks, struct NlaTrack *nlt, bool do_id_user)
|
||||
{
|
||||
BKE_nlatrack_remove(tracks, nlt);
|
||||
BKE_nlatrack_free(nlt, do_id_user);
|
||||
}
|
||||
|
||||
/* *************************************************** */
|
||||
/* NLA Evaluation <-> Editing Stuff */
|
||||
|
||||
|
@ -91,4 +91,24 @@ TEST(nla_track, BKE_nlatrack_remove_strip)
|
||||
EXPECT_EQ(-1, BLI_findindex(&track.strips, &strip2));
|
||||
}
|
||||
|
||||
TEST(nla_track, BKE_nlatrack_remove_and_free)
|
||||
{
|
||||
AnimData adt{};
|
||||
NlaTrack *track1;
|
||||
NlaTrack *track2;
|
||||
|
||||
// Add NLA tracks to the Animation Data.
|
||||
track1 = BKE_nlatrack_add(&adt, NULL, false);
|
||||
track2 = BKE_nlatrack_add(&adt, track1, false);
|
||||
|
||||
// ensure we have 2 tracks in the track.
|
||||
EXPECT_EQ(2, BLI_listbase_count(&adt.nla_tracks));
|
||||
|
||||
BKE_nlatrack_remove_and_free(&adt.nla_tracks, track2, false);
|
||||
EXPECT_EQ(1, BLI_listbase_count(&adt.nla_tracks));
|
||||
|
||||
// ensure the correct track was removed.
|
||||
EXPECT_EQ(-1, BLI_findindex(&adt.nla_tracks, track2));
|
||||
}
|
||||
|
||||
} // namespace blender::bke::tests
|
||||
|
@ -590,7 +590,7 @@ void ED_animedit_unlink_action(
|
||||
|
||||
if (nlt->strips.first == NULL) {
|
||||
BLI_assert(nstrip == NULL);
|
||||
BKE_nlatrack_free(&adt->nla_tracks, nlt, true);
|
||||
BKE_nlatrack_remove_and_free(&adt->nla_tracks, nlt, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
|
||||
/* call delete on this track - deletes all strips too */
|
||||
BKE_nlatrack_free(&adt->nla_tracks, nlt, true);
|
||||
BKE_nlatrack_remove_and_free(&adt->nla_tracks, nlt, true);
|
||||
ale->update = ANIM_UPDATE_DEPS;
|
||||
}
|
||||
}
|
||||
|
@ -593,7 +593,7 @@ static void rna_NlaTrack_remove(
|
||||
return;
|
||||
}
|
||||
|
||||
BKE_nlatrack_free(&adt->nla_tracks, track, true);
|
||||
BKE_nlatrack_remove_and_free(&adt->nla_tracks, track, true);
|
||||
RNA_POINTER_INVALIDATE(track_ptr);
|
||||
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user