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:
authorJacques Lucke <jacques@blender.org>2020-08-11 14:32:07 +0300
committerJacques Lucke <jacques@blender.org>2020-08-11 14:32:07 +0300
commite11aa3edddf54b451645b5f32775559b5af7ee1a (patch)
treec401f07c421094f0295f602d3832601d6526693c /source/blender/python/intern/bpy_operator.c
parent6d888133da1ce31f4cd68f44d1209534173b4562 (diff)
Python: don't remove existing context overrides when calling an operator
Reviewers: campbellbarton, brecht Differential Revision: https://developer.blender.org/D8532
Diffstat (limited to 'source/blender/python/intern/bpy_operator.c')
-rw-r--r--source/blender/python/intern/bpy_operator.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 4b2b5f129a7..274c1934e9e 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -227,7 +227,14 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
context_dict_back = CTX_py_dict_get(C);
- CTX_py_dict_set(C, (void *)context_dict);
+ /**
+ * It might be that there is already a Python context override. We don't want to remove that
+ * except when this operator call sets a new override explicitly. This is necessary so that
+ * called operator runs in the same context as the calling code by default.
+ */
+ if (context_dict != NULL) {
+ CTX_py_dict_set(C, (void *)context_dict);
+ }
Py_XINCREF(context_dict); /* so we done loose it */
if (WM_operator_poll_context((bContext *)C, ot, context) == false) {