diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-01-10 18:36:08 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-01-10 18:36:08 +0400 |
commit | 127b5423d6203d521acb2b96b7de5534e8dbe79a (patch) | |
tree | 4b01e967d7a82a9151f7dd878348cb8b5165a4ed /source | |
parent | 983e5fe5f1431e268ad7dd0d0e8fbdb79bbf3a13 (diff) |
Another fix for bpy.props getters/setters: PyC_AsArray does a refcount decrement internally on errors, need to skip Py_DECREF in that case to avoid negative refcounts.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 026b59244d3..bd3fc95cd7e 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -388,14 +388,17 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert values[i] = false; } else { - if (ret && PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") < 0) { + if (PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") < 0) { printf_func_error(py_func); for (i = 0; i < len; ++i) values[i] = false; - } - Py_DECREF(ret); + /* PyC_AsArray decrements refcount internally on error */ + } + else { + Py_DECREF(ret); + } } if (use_gil) @@ -619,14 +622,17 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA values[i] = 0; } else { - if (ret && PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") < 0) { + if (PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") < 0) { printf_func_error(py_func); for (i = 0; i < len; ++i) values[i] = 0; - } - Py_DECREF(ret); + /* PyC_AsArray decrements refcount internally on error */ + } + else { + Py_DECREF(ret); + } } if (use_gil) @@ -850,14 +856,17 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR values[i] = 0.0f; } else { - if (ret && PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") < 0) { + if (PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") < 0) { printf_func_error(py_func); for (i = 0; i < len; ++i) values[i] = 0.0f; - } - Py_DECREF(ret); + /* PyC_AsArray decrements refcount internally on error */ + } + else { + Py_DECREF(ret); + } } if (use_gil) |