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:
authorBastien Montagne <montagne29@wanadoo.fr>2019-01-16 21:41:29 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-01-16 21:43:53 +0300
commit81022000063c1fe84d85e8de416d8ab0c2c4c516 (patch)
tree01db45c9a9f3e87b107b2d61904080261cecf730 /source/blender/python
parentfeaf846f93913840b523843c63ef67dfa82379cc (diff)
Cleanup/sanitize usages of G.debug_value.
There was no documentation at all, some very bad practices (like using G.debug_value > 0 as some sort of global debug print switch), and even an overlapping use of '1' value... Also, python setter did not check for valid range (since this is a short, not an int).
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_app.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index bba9eee0316..01c8573f589 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -297,7 +297,7 @@ static PyObject *bpy_app_binary_path_python_get(PyObject *self, void *UNUSED(clo
}
PyDoc_STRVAR(bpy_app_debug_value_doc,
-"Int, number which can be set to non-zero values for testing purposes"
+"Short, number which can be set to non-zero values for testing purposes"
);
static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
@@ -313,7 +313,13 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void
return -1;
}
- G.debug_value = param;
+ if (param < SHRT_MIN || param > SHRT_MAX) {
+ PyErr_SetString(PyExc_ValueError,
+ "bpy.app.debug_value can only be set to short range [-32768, 32767]");
+ return -1;
+ }
+
+ G.debug_value = (short)param;
WM_main_add_notifier(NC_WINDOW, NULL);