Fix T73727: Invalid event.type for Gizmo.modal callback
This commit is contained in:
parent
eaea5c8904
commit
f874f6817d
Notes:
blender-bot
2023-02-14 19:01:09 +01:00
Referenced by issue blender/blender-addons#73727, Gizmo.modal(): current value '20514' matches no enum in 'Event', '(null)', 'type'
|
@ -547,15 +547,32 @@ static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
/* handle gizmo */
|
||||
wmGizmoFnModal modal_fn = gz->custom_modal ? gz->custom_modal : gz->type->modal;
|
||||
if (modal_fn) {
|
||||
/* Ugly hack to ensure Python won't get 'EVT_MODAL_MAP' which isn't supported, see T73727.
|
||||
* note that we could move away from wrapping modal gizmos in a modal operator,
|
||||
* since it's causing the need for code like this. */
|
||||
wmEvent *evil_event = (wmEvent *)event;
|
||||
short event_modal_val = 0;
|
||||
|
||||
if (event->type == EVT_MODAL_MAP) {
|
||||
event_modal_val = evil_event->val;
|
||||
evil_event->type = evil_event->prevtype;
|
||||
evil_event->val = evil_event->prevval;
|
||||
}
|
||||
|
||||
int modal_retval = modal_fn(C, gz, event, mtweak->flag);
|
||||
|
||||
if (event_modal_val != 0) {
|
||||
evil_event->type = EVT_MODAL_MAP;
|
||||
evil_event->val = event_modal_val;
|
||||
}
|
||||
|
||||
if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) {
|
||||
gizmo_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
/* Ugly hack to send gizmo events */
|
||||
((wmEvent *)event)->type = EVT_GIZMO_UPDATE;
|
||||
evil_event->type = EVT_GIZMO_UPDATE;
|
||||
}
|
||||
|
||||
/* always return PASS_THROUGH so modal handlers
|
||||
|
|
Loading…
Reference in New Issue