Page MenuHome

Grease Pencil: L (key) / cmd z / crash
Closed, ResolvedPublic

Description

hi there

it happens that blender grease pencil crashes regularly, when I'm in drawing modus and press:
l (L Key) - then cmd+z

best
jadi

System Information
Operating system:
Graphics card:

Blender Version
Broken: (example: 2.80, edbf15d3c044, master, 2018-11-28, as found on the splash screen)
Worked: (optional)

Short description of error

Exact steps for others to reproduce the error
Based on the default startup or an attached .blend file (as simple as possible).

Event Timeline

hi there

it happens that blender grease pencil crashes regularly, when I'm in drawing modus and press:
l (L Key) - then cmd+z

best
jadi

Antonio Vazquez (antoniov) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Aug 8 2019, 5:24 PM

@Charlie Jolly (charlie) The error is gpencil_paint.c

case GP_PAINTMODE_DRAW: {
          GP_Sculpt_Guide *guide = &p->scene->toolsettings->gp_sculpt.guide;
          if (guide->use_guide) {
            ED_workspace_status_text(

The guide is NULL.

I assign to you. If you don't find the problem let me know.

I have seen after undo, the p has NaN

static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
  tGPsdata *p = op->customdata;

I don't know why. It looks the Undo is running while the modal operator is still running.

@Campbell Barton (campbellbarton) any idea here?

Philipp Oeser (lichtwerk) renamed this task from L (key) / cmd z / crash to Grease Pencil: L (key) / cmd z / crash.Aug 9 2019, 9:43 AM

@Philipp Oeser (lichtwerk) Not sure this problem is only GP. I tested and the problem is the customdata of the operator is corrupted when use Undo. Not sure if this can be a problem for more operators.

@Antonio Vazquez (antoniov) gpencil_paint.c has undo function but gpencil_primitive.c doesn't. This might be the cause.

Not sure what OPTYPE_UNDO does in this case.

@Charlie Jolly (charlie) No idea...this was old code done before I enter in GP project. If you can, try your ideas and maybe works.

@Charlie Jolly (charlie) For me fails always.

  1. Open 2D template
  2. Draw something
  3. Press L
  4. Press Ctrl+Z
  5. Crash

@Charlie Jolly (charlie) Proposed fix:

diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 06ff0e744b9..894fb6eced4 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -3460,12 +3460,18 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
   /* We don't pass on key events, GP is used with key-modifiers -
    * prevents Dkey to insert drivers. */
   if (ISKEYBOARD(event->type)) {
-    if (ELEM(event->type, LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY, ZKEY)) {
+    if (ELEM(event->type, LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY)) {
       /* allow some keys:
        *   - for frame changing [#33412]
        *   - for undo (during sketching sessions)
        */
     }
+    else if (event->type == ZKEY) {
+      if (event->ctrl) {
+        p->status = GP_STATUS_DONE;
+        estate = OPERATOR_FINISHED;
+      }
+    }
     else if (ELEM(event->type, PAD0, PAD1, PAD2, PAD3, PAD4, PAD5, PAD6, PAD7, PAD8, PAD9)) {
       /* allow numpad keys so that camera/view manipulations can still take place
        * - PAD0 in particular is really important for Grease Pencil drawing,

@Antonio Vazquez (antoniov) I've managed to finally reproduce the bug and your fix works.

I can commit the fix under my name but might be better for you to commit as it is your fix!