Commit: 09f2aa938248bedebf7e801fabd833055627fe46
Author: Joshua Leung
Date:   Fri Apr 17 13:32:57 2015 +1200
Branches: master
https://developer.blender.org/rB09f2aa938248bedebf7e801fabd833055627fe46

Fix T44412: Crash when trying to paint on a GPencil frame when the frames are 
out of order

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

M       source/blender/blenkernel/intern/gpencil.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index ba4077e..38a8429 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -129,7 +129,7 @@ void BKE_gpencil_free(bGPdata *gpd)
 /* add a new gp-frame to the given layer */
 bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
 {
-       bGPDframe *gpf, *gf;
+       bGPDframe *gpf = NULL, *gf = NULL;
        short state = 0;
        
        /* error checking (neg frame only if they are not allowed in Blender!) 
*/
@@ -160,8 +160,14 @@ bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
        
        /* check whether frame was added successfully */
        if (state == -1) {
+               printf("Error: Frame (%d) existed already for this layer. Using 
existing frame\n", cframe);
+               
+               /* free the newly created one, and use the old one instead */
                MEM_freeN(gpf);
-               printf("Error: frame (%d) existed already for this layer\n", 
cframe);
+               
+               /* return existing frame instead... */
+               BLI_assert(gf != NULL);
+               gpf = gf;
        }
        else if (state == 0) {
                /* add to end then! */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to