Bugfix [#28308] Crashes when individual channels are moved in Action
authorJoshua Leung <aligorith@gmail.com>
Sun, 21 Aug 2011 07:08:15 +0000 (07:08 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 21 Aug 2011 07:08:15 +0000 (07:08 +0000)
Editor

source/blender/editors/animation/anim_channels_edit.c

index ffa0b2d5ff5bdac181239fa505e3d5a45b02ba15..e993faa71aa1c5720c99835e74f4b4c1025545a0 100644 (file)
@@ -1042,11 +1042,6 @@ static void rearrange_action_channels (bAnimContext *ac, bAction *act, short mod
 static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
 {
        bAnimContext ac;
-       
-       ListBase anim_data = {NULL, NULL};
-       bAnimListElem *ale;
-       int filter;
-       
        short mode;
        
        /* get editor data */
@@ -1056,43 +1051,51 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
        /* get mode */
        mode= RNA_enum_get(op->ptr, "direction");
        
-       /* get animdata blocks */
-       // XXX: hierarchy visibility is provisional atm... might be wrong decision!
-       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
-       ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-       
-       for (ale = anim_data.first; ale; ale = ale->next) {
-               AnimData *adt= ale->data;
+       /* method to move channels depends on the editor */
+       if (ac.datatype == ANIMCONT_GPENCIL) {
+               /* Grease Pencil channels */
+               printf("Grease Pencil not supported for moving yet\n");
+       }
+       else if (ac.datatype == ANIMCONT_ACTION) {
+               /* Directly rearrange action's channels */
+               rearrange_action_channels(&ac, ac.data, mode);
+       }
+       else {
+               ListBase anim_data = {NULL, NULL};
+               bAnimListElem *ale;
+               int filter;
                
-               switch (ac.datatype) {
-                       case ANIMCONT_NLA: /* NLA-tracks only */
-                               rearrange_nla_channels(&ac, adt, mode);
-                               break;
+               /* get animdata blocks */
+               filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
+               ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+               
+               for (ale = anim_data.first; ale; ale = ale->next) {
+                       AnimData *adt= ale->data;
                        
-                       case ANIMCONT_DRIVERS: /* Drivers list only */
-                               rearrange_driver_channels(&ac, adt, mode);
-                               break;
-                               
-                       case ANIMCONT_GPENCIL: /* Grease Pencil channels */
-                               // FIXME: this case probably needs to get moved out of here or treated specially...
-                               printf("grease pencil not supported for moving yet\n");
-                               break;
+                       switch (ac.datatype) {
+                               case ANIMCONT_NLA: /* NLA-tracks only */
+                                       rearrange_nla_channels(&ac, adt, mode);
+                                       break;
                                
-                       case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
+                               case ANIMCONT_DRIVERS: /* Drivers list only */
+                                       rearrange_driver_channels(&ac, adt, mode);
+                                       break;
                                
-                       default: /* some collection of actions */
-                               // FIXME: actions should only be considered once!
-                               if (adt->action)
-                                       rearrange_action_channels(&ac, adt->action, mode);
-                               else if (G.f & G_DEBUG)
-                                       printf("animdata has no action\n");
-                               break;
+                               case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
+                                       
+                               default: /* some collection of actions */
+                                       if (adt->action)
+                                               rearrange_action_channels(&ac, adt->action, mode);
+                                       else if (G.f & G_DEBUG)
+                                               printf("Animdata has no action\n");
+                                       break;
+                       }
                }
+               
+               /* free temp data */
+               BLI_freelistN(&anim_data);
        }
        
-       /* free temp data */
-       BLI_freelistN(&anim_data);
-       
        /* send notifier that things have changed */
        WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);