[Bf-blender-cvs] [84bd9e284e0] master: GPencil: Fix unreported error using Grab sculpt in empty frame

Antonio Vazquez noreply at git.blender.org
Wed Sep 18 17:38:00 CEST 2019


Commit: 84bd9e284e06d886c24701bcd2b78b3d24617cb3
Author: Antonio Vazquez
Date:   Wed Sep 18 17:37:38 2019 +0200
Branches: master
https://developer.blender.org/rB84bd9e284e06d886c24701bcd2b78b3d24617cb3

GPencil: Fix unreported error using Grab sculpt in empty frame

When the grab brush was used in an empty frame, a new frame was created, but as the depsgraph was no tagged, the evaluated data was wrong and the Grab hash failed.

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

M	source/blender/editors/gpencil/gpencil_brush.c

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

diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 2a2e7c21df4..4a65bbff454 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -1463,7 +1463,7 @@ static bool gpsculpt_brush_poll(bContext *C)
 
 /* Init Sculpt Stroke ---------------------------------- */
 
-static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
+static void gpsculpt_brush_init_stroke(bContext *C, tGP_BrushEditData *gso)
 {
   bGPdata *gpd = gso->gpd;
 
@@ -1487,9 +1487,11 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
        * - This is useful when animating as it saves that "uh-oh" moment when you realize you've
        *   spent too much time editing the wrong frame.
        */
-      // XXX: should this be allowed when framelock is enabled?
       if (gpf->framenum != cfra) {
         BKE_gpencil_frame_addcopy(gpl, cfra);
+        /* Need tag to recalculate evaluated data to avoid crashes. */
+        DEG_id_tag_update(&gso->gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
+        WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
       }
     }
   }
@@ -2079,7 +2081,7 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve
     ARegion *ar = CTX_wm_region(C);
 
     /* ensure that we'll have a new frame to draw on */
-    gpsculpt_brush_init_stroke(gso);
+    gpsculpt_brush_init_stroke(C, gso);
 
     /* apply first dab... */
     gso->is_painting = true;
@@ -2194,7 +2196,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
         gso->is_painting = true;
         gso->first = true;
 
-        gpsculpt_brush_init_stroke(gso);
+        gpsculpt_brush_init_stroke(C, gso);
         gpsculpt_brush_apply_event(C, op, event);
         break;



More information about the Bf-blender-cvs mailing list