[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42585] trunk/blender/source/blender/ windowmanager: add WM_operator_call_notest() for operators that need to call themselves within invoke functions without being freed .

Campbell Barton ideasman42 at gmail.com
Mon Dec 12 19:52:23 CET 2011


Revision: 42585
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42585
Author:   campbellbarton
Date:     2011-12-12 18:52:18 +0000 (Mon, 12 Dec 2011)
Log Message:
-----------
add WM_operator_call_notest() for operators that need to call themselves within invoke functions without being freed.

Modified Paths:
--------------
    trunk/blender/source/blender/windowmanager/WM_api.h
    trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/windowmanager/WM_api.h
===================================================================
--- trunk/blender/source/blender/windowmanager/WM_api.h	2011-12-12 18:25:52 UTC (rev 42584)
+++ trunk/blender/source/blender/windowmanager/WM_api.h	2011-12-12 18:52:18 UTC (rev 42585)
@@ -191,6 +191,7 @@
 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);

Modified: trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_event_system.c	2011-12-12 18:25:52 UTC (rev 42584)
+++ trunk/blender/source/blender/windowmanager/intern/wm_event_system.c	2011-12-12 18:52:18 UTC (rev 42585)
@@ -597,6 +597,20 @@
 	
 }
 
+/* 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 @@
 	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)
 {

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2011-12-12 18:25:52 UTC (rev 42584)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2011-12-12 18:52:18 UTC (rev 42585)
@@ -802,7 +802,7 @@
 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 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 */




More information about the Bf-blender-cvs mailing list