[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53702] trunk/blender/source/blender/ python/intern/bpy_props.c: Fix for bpy.props getter/setter callbacks.

Lukas Toenne lukas.toenne at googlemail.com
Thu Jan 10 13:32:15 CET 2013


Revision: 53702
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53702
Author:   lukastoenne
Date:     2013-01-10 12:32:09 +0000 (Thu, 10 Jan 2013)
Log Message:
-----------
Fix for bpy.props getter/setter callbacks. These were missing a valid GIL state when being called outside the UI context.

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_props.c

Modified: trunk/blender/source/blender/python/intern/bpy_props.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_props.c	2013-01-10 12:07:01 UTC (rev 53701)
+++ trunk/blender/source/blender/python/intern/bpy_props.c	2013-01-10 12:32:09 UTC (rev 53702)
@@ -243,6 +243,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int value;
 
@@ -252,6 +254,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -277,6 +284,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -291,6 +301,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 
 	BLI_assert(py_data != NULL);
@@ -299,6 +311,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_SET];
 
 	args = PyTuple_New(2);
@@ -322,6 +339,9 @@
 
 		Py_DECREF(ret);
 	}
+	
+	if (use_gil)
+		PyGILState_Release(gilstate);
 
 	if (!is_write_ok) {
 		pyrna_write_set(false);
@@ -335,6 +355,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int i, len = RNA_property_array_length(ptr, prop);
 
@@ -344,6 +366,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -371,6 +398,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -384,6 +414,8 @@
 	PyObject *self;
 	PyObject *ret;
 	PyObject *py_values;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int len = RNA_property_array_length(ptr, prop);
 
@@ -393,6 +425,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_SET];
 
 	args = PyTuple_New(2);
@@ -422,6 +459,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -434,6 +474,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int value;
 
@@ -443,6 +485,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -468,6 +515,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -482,6 +532,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 
 	BLI_assert(py_data != NULL);
@@ -490,6 +542,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_SET];
 
 	args = PyTuple_New(2);
@@ -514,6 +571,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -526,6 +586,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int i, len = RNA_property_array_length(ptr, prop);
 
@@ -535,6 +597,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -562,6 +629,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -575,6 +645,8 @@
 	PyObject *self;
 	PyObject *ret;
 	PyObject *py_values;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int len = RNA_property_array_length(ptr, prop);
 
@@ -584,6 +656,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_SET];
 
 	args = PyTuple_New(2);
@@ -613,6 +690,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -625,6 +705,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	float value;
 
@@ -634,6 +716,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -659,6 +746,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -673,6 +763,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 
 	BLI_assert(py_data != NULL);
@@ -681,6 +773,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_SET];
 
 	args = PyTuple_New(2);
@@ -705,6 +802,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -717,6 +817,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int i, len = RNA_property_array_length(ptr, prop);
 
@@ -726,6 +828,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -753,6 +860,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -766,6 +876,8 @@
 	PyObject *self;
 	PyObject *ret;
 	PyObject *py_values;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int len = RNA_property_array_length(ptr, prop);
 
@@ -775,6 +887,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_SET];
 
 	args = PyTuple_New(2);
@@ -804,6 +921,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -816,6 +936,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 
 	BLI_assert(py_data != NULL);
@@ -824,6 +946,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -855,6 +982,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -867,6 +997,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int length;
 
@@ -876,6 +1008,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -894,6 +1031,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -908,6 +1048,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	PyObject *py_value;
 
@@ -917,6 +1059,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_SET];
 
 	args = PyTuple_New(2);
@@ -947,6 +1094,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -959,6 +1109,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 	int value;
 
@@ -968,6 +1120,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_GET];
 
 	args = PyTuple_New(1);
@@ -993,6 +1150,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}
@@ -1007,6 +1167,8 @@
 	PyObject *args;
 	PyObject *self;
 	PyObject *ret;
+	PyGILState_STATE gilstate;
+	bool use_gil;
 	const int is_write_ok = pyrna_write_check();
 
 	BLI_assert(py_data != NULL);
@@ -1015,6 +1177,11 @@
 		pyrna_write_set(true);
 	}
 
+	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+
+	if (use_gil)
+		gilstate = PyGILState_Ensure();
+
 	py_func = py_data[BPY_DATA_CB_SLOT_SET];
 
 	args = PyTuple_New(2);
@@ -1039,6 +1206,9 @@
 		Py_DECREF(ret);
 	}
 
+	if (use_gil)
+		PyGILState_Release(gilstate);
+
 	if (!is_write_ok) {
 		pyrna_write_set(false);
 	}




More information about the Bf-blender-cvs mailing list