Bugfix #26651
authorTon Roosendaal <ton@blender.org>
Thu, 31 Mar 2011 15:26:51 +0000 (15:26 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 31 Mar 2011 15:26:51 +0000 (15:26 +0000)
If greasepencil became active, making Blender area full or restore
screen from full, the greasepencil handler was still running, using
outdated area pointer. This crashed Blender.

Now greasepencil modal() ends on the case its own stored area does
not exist anymore.

source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/screen/screen_edit.c

index 2f2f9c3..17e7c0c 100644 (file)
@@ -1594,6 +1594,18 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event)
        return OPERATOR_RUNNING_MODAL;
 }
 
+/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
+static int gpencil_area_exists(bContext *C, ScrArea *satest)
+{
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa;
+       
+       for(sa= sc->areabase.first; sa; sa= sa->next)
+               if(sa==satest)
+                       return 1;
+       return 0;
+}
+
 /* events handling during interactive drawing part of operator */
 static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event)
 {
@@ -1659,6 +1671,8 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event)
                }
        }
        
+       
+       
        /* handle mode-specific events */
        if (p->status == GP_STATUS_PAINTING) {
                /* handle painting mouse-movements? */
@@ -1705,8 +1719,12 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event)
                }
        }
        
-       /* update status indicators - cursor, header, etc. */
-       gpencil_draw_status_indicators(p);
+       /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
+       if(0==gpencil_area_exists(C, p->sa))
+               estate= OPERATOR_CANCELLED;
+       else
+               /* update status indicators - cursor, header, etc. */
+               gpencil_draw_status_indicators(p);
        
        /* process last operations before exiting */
        switch (estate) {
index a40c623..39da86b 100644 (file)
@@ -1585,6 +1585,9 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa)
                   are no longer in the same screen */
                for(ar=sa->regionbase.first; ar; ar=ar->next)
                        uiFreeBlocks(C, &ar->uiblocks);
+               
+               /* prevent hanging header prints */
+               ED_area_headerprint(sa, NULL);
        }
 
        if(sa && sa->full) {