[Bf-blender-cvs] [b2411fe269c] blender2.8: Fix unneeded/unwanted user counter when freeing CoW NLA

Sergey Sharybin noreply at git.blender.org
Mon Oct 29 11:48:44 CET 2018


Commit: b2411fe269caa80b61745209486ed0e8fca8bc79
Author: Sergey Sharybin
Date:   Mon Oct 29 11:13:19 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBb2411fe269caa80b61745209486ed0e8fca8bc79

Fix unneeded/unwanted user counter when freeing CoW NLA

===================================================================

M	source/blender/blenkernel/BKE_nla.h
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/nla.c
M	source/blender/editors/space_action/action_data.c
M	source/blender/editors/space_nla/nla_channels.c
M	source/blender/editors/space_nla/nla_edit.c
M	source/blender/makesrna/intern/rna_animation.c
M	source/blender/makesrna/intern/rna_nla.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index 37929bae042..87240885b2c 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -47,9 +47,9 @@ struct PropertyRNA;
 /* ----------------------------- */
 /* Data Management */
 
-void BKE_nlastrip_free(ListBase *strips, struct NlaStrip *strip);
-void BKE_nlatrack_free(ListBase *tracks, struct NlaTrack *nlt);
-void BKE_nla_tracks_free(ListBase *tracks);
+void BKE_nlastrip_free(ListBase *strips, struct NlaStrip *strip, bool do_id_user);
+void BKE_nlatrack_free(ListBase *tracks, struct NlaTrack *nlt, bool do_id_user);
+void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user);
 
 struct NlaStrip *BKE_nlastrip_copy(struct Main *bmain, struct NlaStrip *strip, const bool use_same_action);
 struct NlaTrack *BKE_nlatrack_copy(struct Main *bmain, struct NlaTrack *nlt, const bool use_same_actions);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index f591037322d..f531dbffdff 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -246,7 +246,7 @@ void BKE_animdata_free(ID *id, const bool do_id_user)
 			}
 
 			/* free nla data */
-			BKE_nla_tracks_free(&adt->nla_tracks);
+			BKE_nla_tracks_free(&adt->nla_tracks, do_id_user);
 
 			/* free drivers - stored as a list of F-Curves */
 			free_fcurves(&adt->drivers);
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 9850ce9b517..8c5cc6f2b38 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -76,7 +76,7 @@
 /* Remove the given NLA strip from the NLA track it occupies, free the strip's data,
  * and the strip itself.
  */
-void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip)
+void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
 {
 	NlaStrip *cs, *csn;
 
@@ -87,12 +87,13 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip)
 	/* free child-strips */
 	for (cs = strip->strips.first; cs; cs = csn) {
 		csn = cs->next;
-		BKE_nlastrip_free(&strip->strips, cs);
+		BKE_nlastrip_free(&strip->strips, cs, do_id_user);
 	}
 
 	/* remove reference to action */
-	if (strip->act)
+	if (strip->act != NULL && do_id_user) {
 		id_us_min(&strip->act->id);
+	}
 
 	/* free remapping info */
 	//if (strip->remap)
@@ -114,7 +115,7 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip)
 /* Remove the given NLA track from the set of NLA tracks, free the track's data,
  * and the track itself.
  */
-void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt)
+void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
 {
 	NlaStrip *strip, *stripn;
 
@@ -125,7 +126,7 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt)
 	/* free strips */
 	for (strip = nlt->strips.first; strip; strip = stripn) {
 		stripn = strip->next;
-		BKE_nlastrip_free(&nlt->strips, strip);
+		BKE_nlastrip_free(&nlt->strips, strip, do_id_user);
 	}
 
 	/* free NLA track itself now */
@@ -138,7 +139,7 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt)
 /* 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
  */
-void BKE_nla_tracks_free(ListBase *tracks)
+void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
 {
 	NlaTrack *nlt, *nltn;
 
@@ -149,7 +150,7 @@ void BKE_nla_tracks_free(ListBase *tracks)
 	/* free tracks one by one */
 	for (nlt = tracks->first; nlt; nlt = nltn) {
 		nltn = nlt->next;
-		BKE_nlatrack_free(tracks, nlt);
+		BKE_nlatrack_free(tracks, nlt, do_id_user);
 	}
 
 	/* clear the list's pointers to be safe */
@@ -752,7 +753,7 @@ void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip)
 	}
 
 	/* free the meta-strip now */
-	BKE_nlastrip_free(strips, strip);
+	BKE_nlastrip_free(strips, strip, true);
 }
 
 /* Remove meta-strips (i.e. flatten the list of strips) from the top-level of the list of strips
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index 8d4596a79a7..3f8155627e3 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -566,11 +566,11 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act,
 
 						if (strip->act == act) {
 							/* Remove this strip, and the track too if it doesn't have anything else */
-							BKE_nlastrip_free(&nlt->strips, strip);
+							BKE_nlastrip_free(&nlt->strips, strip, true);
 
 							if (nlt->strips.first == NULL) {
 								BLI_assert(nstrip == NULL);
-								BKE_nlatrack_free(&adt->nla_tracks, nlt);
+								BKE_nlatrack_free(&adt->nla_tracks, nlt, true);
 							}
 						}
 					}
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index eea55109136..002eeea9746 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -731,7 +731,7 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
 				adt->flag &= ~ADT_NLA_SOLO_TRACK;
 
 			/* call delete on this track - deletes all strips too */
-			BKE_nlatrack_free(&adt->nla_tracks, nlt);
+			BKE_nlatrack_free(&adt->nla_tracks, nlt, true);
 		}
 	}
 
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index b304b071ee0..63de4ec9dea 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -1160,14 +1160,14 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
 			if (strip->flag & NLASTRIP_FLAG_SELECT) {
 				/* if a strip either side of this was a transition, delete those too */
 				if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
-					BKE_nlastrip_free(&nlt->strips, strip->prev);
+					BKE_nlastrip_free(&nlt->strips, strip->prev, true);
 				if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) {
 					nstrip = nstrip->next;
-					BKE_nlastrip_free(&nlt->strips, strip->next);
+					BKE_nlastrip_free(&nlt->strips, strip->next, true);
 				}
 
 				/* finally, delete this strip */
-				BKE_nlastrip_free(&nlt->strips, strip);
+				BKE_nlastrip_free(&nlt->strips, strip, true);
 			}
 		}
 	}
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 6b014f462b5..ee399ee8648 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -536,7 +536,7 @@ static void rna_NlaTrack_remove(AnimData *adt, bContext *C, ReportList *reports,
 		return;
 	}
 
-	BKE_nlatrack_free(&adt->nla_tracks, track);
+	BKE_nlatrack_free(&adt->nla_tracks, track, true);
 	RNA_POINTER_INVALIDATE(track_ptr);
 
 	WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 025bc705560..48be6421f36 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -383,7 +383,7 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo
 	if (BKE_nlastrips_add_strip(&track->strips, strip) == 0) {
 		BKE_report(reports, RPT_ERROR,
 		           "Unable to add strip (the track does not have any space to accommodate this new strip)");
-		BKE_nlastrip_free(NULL, strip);
+		BKE_nlastrip_free(NULL, strip, true);
 		return NULL;
 	}
 
@@ -424,7 +424,7 @@ static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *report
 		return;
 	}
 
-	BKE_nlastrip_free(&track->strips, strip);
+	BKE_nlastrip_free(&track->strips, strip, true);
 	RNA_POINTER_INVALIDATE(strip_ptr);
 
 	WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);



More information about the Bf-blender-cvs mailing list