Fix T63090: Delete keyframe reports invalid for multiple objects
authorCampbell Barton <ideasman42@gmail.com>
Fri, 19 Jul 2019 08:43:12 +0000 (18:43 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 19 Jul 2019 08:43:12 +0000 (18:43 +1000)
source/blender/editors/animation/keyframing.c

index cab821e52ef9f848f2812aacbf6bbdf10db48323..2e7ed7eae34024967080b364af7228a8826036bc 100644 (file)
@@ -2249,10 +2249,16 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
   Scene *scene = CTX_data_scene(C);
   float cfra = (float)CFRA;
 
+  int selected_objects_len = 0;
+  int selected_objects_success_len = 0;
+  int success_multi = 0;
+
   CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
     ID *id = &ob->id;
     int success = 0;
 
+    selected_objects_len += 1;
+
     /* just those in active action... */
     if ((ob->adt) && (ob->adt->action)) {
       AnimData *adt = ob->adt;
@@ -2317,22 +2323,29 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
       DEG_id_tag_update(&ob->adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH);
     }
 
-    /* report success (or failure) */
+    /* Only for reporting. */
     if (success) {
-      BKE_reportf(op->reports,
-                  RPT_INFO,
-                  "Object '%s' successfully had %d keyframes removed",
-                  id->name + 2,
-                  success);
-    }
-    else {
-      BKE_reportf(op->reports, RPT_ERROR, "No keyframes removed from Object '%s'", id->name + 2);
+      selected_objects_success_len += 1;
+      success_multi += success;
     }
 
     DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
   }
   CTX_DATA_END;
 
+  /* report success (or failure) */
+  if (selected_objects_success_len) {
+    BKE_reportf(op->reports,
+                RPT_INFO,
+                "%d object(s) successfully had %d keyframes removed",
+                selected_objects_success_len,
+                success_multi);
+  }
+  else {
+    BKE_reportf(
+        op->reports, RPT_ERROR, "No keyframes removed from %d object(s)", selected_objects_len);
+  }
+
   /* send updates */
   WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);