Fix T48196: Crash enabling modal operator in exec

Not good practice, but better not crash.
This commit is contained in:
Campbell Barton 2016-06-21 15:02:10 +10:00
parent 994dd5c7c1
commit 7cbd1285a5
Notes: blender-bot 2023-02-14 19:48:42 +01:00
Referenced by issue blender/blender-addons#48196, Cannot combine invoke_props_dialog with a modal execution
1 changed files with 4 additions and 1 deletions

View File

@ -793,7 +793,10 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
wm_operator_finished(C, op, repeat);
}
else if (repeat == 0) {
WM_operator_free(op);
/* warning: modal from exec is bad practice, but avoid crashing. */
if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) {
WM_operator_free(op);
}
}
return retval | OPERATOR_HANDLED;