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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-17 10:02:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-03-17 10:02:02 +0300
commit33047585ea19bde496d4c82add0edb9ad6759dd5 (patch)
tree19c7755d1bdd5c277ac1ae71a052b1118a20d88e /source/blender/makesrna/intern/rna_wm.c
parent0277073579411206c2b05cabf5d6354c8c251f1e (diff)
add cancel() method for python defined operators.
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 631af91a5bf..2a51d8b682b 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -828,6 +828,30 @@ static void operator_draw(bContext *C, wmOperator *op)
RNA_parameter_list_free(&list);
}
+/* same as exec(), but call cancel */
+static int operator_cancel(bContext *C, wmOperator *op)
+{
+ PointerRNA opr;
+ ParameterList list;
+ FunctionRNA *func;
+ void *ret;
+ int result;
+
+ RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+ func= RNA_struct_find_function(&opr, "cancel");
+
+ RNA_parameter_list_create(&list, &opr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ op->type->ext.call(C, &opr, func, &list);
+
+ RNA_parameter_get_lookup(&list, "result", &ret);
+ result= *(int*)ret;
+
+ RNA_parameter_list_free(&list);
+
+ return result;
+}
+
void operator_wrapper(wmOperatorType *ot, void *userdata);
void macro_wrapper(wmOperatorType *ot, void *userdata);
@@ -839,7 +863,7 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void *
wmOperatorType dummyot = {NULL};
wmOperator dummyop= {NULL};
PointerRNA dummyotr;
- int have_function[6];
+ int have_function[7];
/* setup dummy operator & operator type to store static properties in */
dummyop.type= &dummyot;
@@ -927,6 +951,7 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void *
dummyot.invoke= (have_function[3])? operator_invoke: NULL;
dummyot.modal= (have_function[4])? operator_modal: NULL;
dummyot.ui= (have_function[5])? operator_draw: NULL;
+ dummyot.cancel= (have_function[6])? operator_cancel: NULL;
WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot);
/* update while blender is running */