Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_paint.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 28a54b20277..169443d855f 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1615,7 +1615,12 @@ static int gpencil_area_exists(bContext *C, ScrArea *satest)
static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event)
{
tGPsdata *p= op->customdata;
- int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */
+ //int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */
+ /* currently, grease pencil conflicts with such operators as undo and set object mode
+ which makes behavior of operator totally unpredictable and crash for some cases.
+ the only way to solve this proper is to ger rid of pointers to data which can
+ chage stored in operator custom data (sergey) */
+ int estate = OPERATOR_RUNNING_MODAL;
// if (event->type == NDOF_MOTION)
// return OPERATOR_PASS_THROUGH;
@@ -1722,13 +1727,18 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event)
/* standard undo/redo shouldn't be allowed to execute or else it causes crashes, so catch it here */
// FIXME: this is a hardcoded hotkey that can't be changed
// TODO: catch redo as well, but how?
- if (event->type == ZKEY) {
+ if (event->type == ZKEY && event->val == KM_RELEASE) {
/* oskey = cmd key on macs as they seem to use cmd-z for undo as well? */
if ((event->ctrl) || (event->oskey)) {
/* just delete last stroke, which will look like undo to the end user */
//printf("caught attempted undo event... deleting last stroke \n");
gpencil_frame_delete_laststroke(p->gpl, p->gpf);
-
+ /* undoing the last line can free p->gpf
+ * note, could do this in a bit more of an elegant way then a search but it at least prevents a crash */
+ if(BLI_findindex(&p->gpl->frames, p->gpf) == -1) {
+ p->gpf= NULL;
+ }
+
/* event handled, so force refresh */
ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */
estate = OPERATOR_RUNNING_MODAL;