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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-12-12 22:52:18 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-12-12 22:52:18 +0400
commit7abc66ba4232a1718d5eb67313f600ed5d77956f (patch)
tree8dad9d577f307af7efceeaa5ab8bc9cfee6ae37e /source
parentba3c6d4d34e9f36f572b63efe7d8ed4914421726 (diff)
add WM_operator_call_notest() for operators that need to call themselves within invoke functions without being freed.
Diffstat (limited to 'source')
-rw-r--r--source/blender/windowmanager/WM_api.h1
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c22
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c4
3 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 5bd95ac2106..61c3da36203 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -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);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 38f26897998..1593f14a76c 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -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)
{
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index fb375f1d61f..004b71307df 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -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 */