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:
authorLukas Toenne <lukas.toenne@googlemail.com>2013-01-10 16:32:09 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-01-10 16:32:09 +0400
commit273cf512dd8915e5360e8dc33471c89ef2a5e836 (patch)
treea3adcae921d89902f06ec536621325139fac113d /source/blender/python
parentc3c3df3aecf885946b52d5eff72c4134a1c9478e (diff)
Fix for bpy.props getter/setter callbacks. These were missing a valid GIL state when being called outside the UI context.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_props.c170
1 files changed, 170 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index b9bfaed54d5..026b59244d3 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -243,6 +243,8 @@ static int bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
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 @@ static int bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
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 @@ static int bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -291,6 +301,8 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
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 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
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 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
+
+ if (use_gil)
+ PyGILState_Release(gilstate);
if (!is_write_ok) {
pyrna_write_set(false);
@@ -335,6 +355,8 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
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 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
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 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -384,6 +414,8 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
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 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
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 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -434,6 +474,8 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
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 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
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 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -482,6 +532,8 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
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 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
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 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -526,6 +586,8 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
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 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
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 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -575,6 +645,8 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
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 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
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 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -625,6 +705,8 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
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 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
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 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -673,6 +763,8 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
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 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
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 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -717,6 +817,8 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
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 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
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 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -766,6 +876,8 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
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 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
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 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -816,6 +936,8 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
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 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
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 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -867,6 +997,8 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
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 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
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 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -908,6 +1048,8 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
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 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
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 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -959,6 +1109,8 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
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 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
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 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}
@@ -1007,6 +1167,8 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
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 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
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 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
Py_DECREF(ret);
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
if (!is_write_ok) {
pyrna_write_set(false);
}