== Action Editor - Pinned Actions Bugfix ==
[blender.git] / source / blender / src / headerbuttons.c
index 18bbba89ce8193f2a2b21e484c69b70cf76368e4..505206ed6e0829c6972e65b1c9d7283424e926f1 100644 (file)
@@ -938,14 +938,14 @@ void do_global_buttons(unsigned short event)
                        break;
                act=ob->action;
                id= (ID *)act;
-
+               
                if (G.saction->actnr== -2){
                                activate_databrowse((ID *)G.saction->action, ID_AC,  0, B_ACTIONBROWSE, &G.saction->actnr, do_global_buttons);
                        return;
                }
-
+               
                if(G.saction->actnr < 0) break;
-
+               
                /*      See if we have selected a valid action */
                for (idtest= G.main->action.first; idtest; idtest= idtest->next) {
                                if(nr==G.saction->actnr) {
@@ -956,7 +956,16 @@ void do_global_buttons(unsigned short event)
                }
 
                if(G.saction->pin) {
-                       G.saction->action= (bAction *)idtest;
+                       if (idtest == NULL) {
+                               /* assign new/copy of pinned action only - messy as it doesn't assign to any obj's */
+                               if (G.saction->action)
+                                       G.saction->action= (bAction *)copy_action(G.saction->action);
+                               else
+                                       G.saction->action= (bAction *)add_empty_action("PinnedAction");
+                       }
+                       else {
+                               G.saction->action= (bAction *)idtest;
+                       }
                        allqueue(REDRAWACTION, 0);
                }
                else {