[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38448] branches/soc-2011-pepper/source/ blender/editors/armature/poselib.c: Bugfix [#27412] PoseLib bug( maybe also corrupted data)

Joshua Leung aligorith at gmail.com
Sun Jul 17 14:37:38 CEST 2011


Revision: 38448
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38448
Author:   aligorith
Date:     2011-07-17 12:37:38 +0000 (Sun, 17 Jul 2011)
Log Message:
-----------
Bugfix [#27412] PoseLib bug(maybe also corrupted data)

* Find first unused frame function was failing to correctly detect
conflicts with the lower bound due to the way that markers are not
stored in sorted order. Fixed by performing additional search passes.

* Fixed some update bugs where there were missing notifiers. Most
noticable when the poselib is being viewed in an Action Editor

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/armature/poselib.c

Modified: branches/soc-2011-pepper/source/blender/editors/armature/poselib.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/armature/poselib.c	2011-07-17 12:30:23 UTC (rev 38447)
+++ branches/soc-2011-pepper/source/blender/editors/armature/poselib.c	2011-07-17 12:37:38 UTC (rev 38448)
@@ -110,22 +110,34 @@
 {
 	TimeMarker *marker;
 	int low=0, high=0;
+	short changed = 0;
 	
 	/* sanity checks */
 	if (ELEM(NULL, act, act->markers.first)) return 1;
 	
-	/* loop over poses finding various values (poses are not stored in chronological order) */
-	for (marker= act->markers.first; marker; marker= marker->next) {
-		/* only increase low if value is 1 greater than low, to find "gaps" where
-		 * poses were removed from the poselib
-		 */
-		if (marker->frame == (low + 1)) 
-			low++;
+	/* As poses are not stored in chronological order, we must iterate over this list 
+	 * a few times until we don't make any new discoveries (mostly about the lower bound).
+	 * Prevents problems with deleting then trying to add new poses [#27412]
+	 */
+	do {
+		changed = 0;
 		
-		/* value replaces high if it is the highest value encountered yet */
-		if (marker->frame > high) 
-			high= marker->frame;
-	}
+		for (marker= act->markers.first; marker; marker= marker->next) {
+			/* only increase low if value is 1 greater than low, to find "gaps" where
+			 * poses were removed from the poselib
+			 */
+			if (marker->frame == (low + 1)) {
+				low++;
+				changed = 1;
+			}
+			
+			/* value replaces high if it is the highest value encountered yet */
+			if (marker->frame > high) {
+				high= marker->frame;
+				changed = 1;
+			}
+		}
+	} while (changed != 0);
 	
 	/* - if low is not equal to high, then low+1 is a gap 
 	 * - if low is equal to high, then high+1 is the next index (add at end) 
@@ -331,6 +343,11 @@
 	/* free temp memory */
 	BLI_dlrbTree_free(&keys);
 	
+	/* send notifiers for this - using keyframe editing notifiers, since action 
+	 * may be being shown in anim editors as active action 
+	 */
+	WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+	
 	return OPERATOR_FINISHED;
 }
 
@@ -555,6 +572,11 @@
 	/* fix active pose number */
 	act->active_marker= 0;
 	
+	/* send notifiers for this - using keyframe editing notifiers, since action 
+	 * may be being shown in anim editors as active action 
+	 */
+	WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+	
 	/* done */
 	return OPERATOR_FINISHED;
 }
@@ -637,6 +659,11 @@
 	BLI_strncpy(marker->name, newname, sizeof(marker->name));
 	BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name));
 	
+	/* send notifiers for this - using keyframe editing notifiers, since action 
+	 * may be being shown in anim editors as active action 
+	 */
+	WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+	
 	/* done */
 	return OPERATOR_FINISHED;
 }




More information about the Bf-blender-cvs mailing list