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:
Diffstat (limited to 'source/blender/python/intern/bpy_props.c')
-rw-r--r--source/blender/python/intern/bpy_props.c181
1 files changed, 123 insertions, 58 deletions
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 385b02f231e..18a39f39e70 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -201,10 +201,12 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
PyTuple_SET_ITEM(ret, 0, func);
Py_INCREF(func);
- if (kw == NULL)
+ if (kw == NULL) {
kw = PyDict_New();
- else
+ }
+ else {
Py_INCREF(kw);
+ }
PyTuple_SET_ITEM(ret, 1, kw);
@@ -282,8 +284,9 @@ static bool bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -313,8 +316,9 @@ static bool bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -342,8 +346,9 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -369,8 +374,9 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -395,8 +401,9 @@ static bool bpy_prop_poll_cb(struct PointerRNA *self, PointerRNA candidate, stru
py_candidate = pyrna_struct_as_instance(&candidate);
py_func = py_data[BPY_DATA_CB_SLOT_POLL];
- if (!is_write_ok)
+ if (!is_write_ok) {
pyrna_write_set(true);
+ }
args = PyTuple_New(2);
PyTuple_SET_ITEM(args, 0, py_self);
@@ -416,8 +423,9 @@ static bool bpy_prop_poll_cb(struct PointerRNA *self, PointerRNA candidate, stru
}
PyGILState_Release(gilstate);
- if (!is_write_ok)
+ if (!is_write_ok) {
pyrna_write_set(false);
+ }
return result;
}
@@ -442,8 +450,9 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -458,15 +467,17 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = false;
+ }
}
else {
if (PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = false;
+ }
/* PyC_AsArray decrements refcount internally on error */
}
@@ -475,8 +486,9 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
}
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -504,8 +516,9 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -532,8 +545,9 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -560,8 +574,9 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -588,8 +603,9 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -617,8 +633,9 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -644,8 +661,9 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -672,8 +690,9 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -688,15 +707,17 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = 0;
+ }
}
else {
if (PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = 0;
+ }
/* PyC_AsArray decrements refcount internally on error */
}
@@ -705,8 +726,9 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
}
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -734,8 +756,9 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -762,8 +785,9 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -790,8 +814,9 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -818,8 +843,9 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -847,8 +873,9 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -874,8 +901,9 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -902,8 +930,9 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -918,15 +947,17 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = 0.0f;
+ }
}
else {
if (PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = 0.0f;
+ }
/* PyC_AsArray decrements refcount internally on error */
}
@@ -935,8 +966,9 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
}
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -964,8 +996,9 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -992,8 +1025,9 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1019,8 +1053,9 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1051,8 +1086,9 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1079,8 +1115,9 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1111,8 +1148,9 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1141,8 +1179,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -1155,8 +1194,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
PyErr_SetString(PyExc_ValueError, "the return value must be a string");
PyC_Err_PrintWithFunc(py_func);
}
- else
+ else {
PyTuple_SET_ITEM(args, 1, py_value);
+ }
ret = PyObject_CallObject(py_func, args);
@@ -1174,8 +1214,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1202,8 +1243,9 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1230,8 +1272,9 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1259,8 +1302,9 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -1286,8 +1330,9 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1423,8 +1468,9 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *
}
}
- if (tmp_icon)
+ if (tmp_icon) {
tmp.icon = icon_id_from_name(tmp_icon);
+ }
items[i] = tmp;
@@ -2139,8 +2185,9 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
return NULL;
}
- if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") == -1)
+ if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") == -1) {
return NULL;
+ }
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2155,7 +2202,9 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
// prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description);
prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
RNA_def_property_array(prop, size);
- if (pydef) RNA_def_property_boolean_array_default(prop, def);
+ if (pydef) {
+ RNA_def_property_boolean_array_default(prop, def);
+ }
RNA_def_property_ui_text(prop, name ? name : id, description);
if (py_tags) {
@@ -2366,8 +2415,9 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
return NULL;
}
- if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") == -1)
+ if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") == -1) {
return NULL;
+ }
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2381,7 +2431,9 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
prop = RNA_def_property(srna, id, PROP_INT, subtype);
RNA_def_property_array(prop, size);
- if (pydef) RNA_def_property_int_array_default(prop, def);
+ if (pydef) {
+ RNA_def_property_int_array_default(prop, def);
+ }
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
@@ -2618,8 +2670,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
return NULL;
}
- if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") == -1)
+ if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") == -1) {
return NULL;
+ }
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2633,7 +2686,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
prop = RNA_def_property(srna, id, PROP_FLOAT, subtype | unit);
RNA_def_property_array(prop, size);
- if (pydef) RNA_def_property_float_array_default(prop, def);
+ if (pydef) {
+ RNA_def_property_float_array_default(prop, def);
+ }
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
@@ -2728,8 +2783,12 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
}
prop = RNA_def_property(srna, id, PROP_STRING, subtype);
- if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
- if (def && def[0]) RNA_def_property_string_default(prop, def);
+ if (maxlen != 0) {
+ RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
+ }
+ if (def && def[0]) {
+ RNA_def_property_string_default(prop, def);
+ }
RNA_def_property_ui_text(prop, name ? name : id, description);
if (py_tags) {
@@ -2890,8 +2949,12 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
}
}
- if (opts & PROP_ENUM_FLAG) prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description);
- else prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description);
+ if (opts & PROP_ENUM_FLAG) {
+ prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description);
+ }
+ else {
+ prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description);
+ }
if (py_tags) {
RNA_def_property_tags(prop, prop_tags);
@@ -2994,8 +3057,9 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_CHECK(PointerProperty, property_flag_items);
ptype = pointer_type_from_py(type, "PointerProperty(...)");
- if (!ptype)
+ if (!ptype) {
return NULL;
+ }
if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup) && !RNA_struct_is_ID(ptype)) {
PyErr_Format(PyExc_TypeError,
"PointerProperty(...) expected an RNA type derived from %.200s or %.200s",
@@ -3077,8 +3141,9 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items);
ptype = pointer_type_from_py(type, "CollectionProperty(...):");
- if (!ptype)
+ if (!ptype) {
return NULL;
+ }
if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup)) {
PyErr_Format(