From 6e14661ad06835a70c7457de50b87da333690f40 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 31 Mar 2011 15:26:51 +0000 Subject: Bugfix #26651 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 | 22 ++++++++++++++++++++-- source/blender/editors/screen/screen_edit.c | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 2f2f9c37bdc..17e7c0c221b 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -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) { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index a40c62360c9..39da86b1962 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -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) { -- cgit v1.2.3