fix [#35156] Edge slide gg shortcut brings up wrong settings.

switch operator types from transform, this would normally be problematic, but transform operators share callbacks so it can be supported.
This commit is contained in:
Campbell Barton 2013-04-30 03:44:03 +00:00
parent cba25a6d90
commit def15f275d
3 changed files with 41 additions and 1 deletions

@ -339,6 +339,7 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
int exit_code;
TransInfo *t = op->customdata;
const enum TfmMode mode_prev = t->mode;
#if 0
// stable 2D mouse coords map to different 3D coords while the 3D mouse is active
@ -362,6 +363,28 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
transformops_exit(C, op);
exit_code &= ~OPERATOR_PASS_THROUGH; /* preventively remove passthrough */
}
else {
if (mode_prev != t->mode) {
/* WARNING: this is not normal to switch operator types
* normally it would not be supported but transform happens
* to share callbacks between differernt operators. */
wmOperatorType *ot_new = NULL;
TransformModeItem *item = transform_modes;
while (item->idname) {
if (item->mode == t->mode) {
ot_new = WM_operatortype_find(item->idname, false);
break;
}
item++;
}
BLI_assert(ot_new != NULL);
if (ot_new) {
WM_operator_type_set(op, ot_new);
}
/* end suspicious code */
}
}
return exit_code;
}

@ -203,10 +203,11 @@ int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, con
/* operator api */
void WM_operator_free (struct wmOperator *op);
void WM_operator_type_set(struct wmOperator *op, struct wmOperatorType *ot);
void WM_operator_stack_clear(struct wmWindowManager *wm);
void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot);
struct wmOperatorType *WM_operatortype_find(const char *idnamem, bool quiet);
struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet);
struct GHashIterator *WM_operatortype_iter(void);
void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *));
void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);

@ -108,6 +108,22 @@ void WM_operator_free(wmOperator *op)
MEM_freeN(op);
}
/**
* Use with extreme care!,
* properties, customdata etc - must be compatible.
*
* \param op Operator to assign the type to.
* \param ot OperatorType to assign.
*/
void WM_operator_type_set(wmOperator *op, wmOperatorType *ot)
{
/* not supported for Python */
BLI_assert(op->py_instance == NULL);
op->type = ot;
op->ptr->type = ot->srna;
}
static void wm_reports_free(wmWindowManager *wm)
{
BKE_reports_clear(&wm->reports);