add WM_operator_call_notest() for operators that need to call themselves within invoke functions without being freed.
This commit is contained in:
parent
ba3c6d4d34
commit
7abc66ba42
@ -191,6 +191,7 @@ struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *
|
||||
int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot);
|
||||
int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, int context);
|
||||
int WM_operator_call (struct bContext *C, struct wmOperator *op);
|
||||
int WM_operator_call_notest(struct bContext *C, struct wmOperator *op);
|
||||
int WM_operator_repeat (struct bContext *C, struct wmOperator *op);
|
||||
int WM_operator_repeat_check(const struct bContext *C, struct wmOperator *op);
|
||||
int WM_operator_name_call (struct bContext *C, const char *opstring, int context, struct PointerRNA *properties);
|
||||
|
@ -597,6 +597,20 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
|
||||
|
||||
}
|
||||
|
||||
/* simply calls exec with basic checks */
|
||||
static int wm_operator_exec_notest(bContext *C, wmOperator *op)
|
||||
{
|
||||
int retval= OPERATOR_CANCELLED;
|
||||
|
||||
if(op==NULL || op->type==NULL || op->type->exec==NULL)
|
||||
return retval;
|
||||
|
||||
retval= op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* for running operators with frozen context (modal handlers, menus)
|
||||
*
|
||||
* warning: do not use this within an operator to call its self! [#29537] */
|
||||
@ -605,6 +619,14 @@ int WM_operator_call(bContext *C, wmOperator *op)
|
||||
return wm_operator_exec(C, op, 0);
|
||||
}
|
||||
|
||||
/* this is intended to be used when an invoke operator wants to call exec on its self
|
||||
* and is basically like running op->type->exec() directly, no poll checks no freeing,
|
||||
* since we assume whoever called invokle will take care of that */
|
||||
int WM_operator_call_notest(bContext *C, wmOperator *op)
|
||||
{
|
||||
return wm_operator_exec_notest(C, op);
|
||||
}
|
||||
|
||||
/* do this operator again, put here so it can share above code */
|
||||
int WM_operator_repeat(bContext *C, wmOperator *op)
|
||||
{
|
||||
|
@ -802,7 +802,7 @@ int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
if (RNA_property_is_set(op->ptr, "filepath")) {
|
||||
return WM_operator_call(C, op);
|
||||
return WM_operator_call_notest(C, op); /* call exec direct */
|
||||
}
|
||||
else {
|
||||
WM_event_add_fileselect(C, op);
|
||||
@ -1637,7 +1637,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
|
||||
static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
if(RNA_property_is_set(op->ptr, "filepath")) {
|
||||
return WM_operator_call(C, op);
|
||||
return WM_operator_call_notest(C, op);
|
||||
}
|
||||
else {
|
||||
/* XXX TODO solve where to get last linked library from */
|
||||
|
Loading…
Reference in New Issue
Block a user