[Bf-blender-cvs] [e11aa3edddf] blender-v2.90-release: Python: don't remove existing context overrides when calling an operator
Jacques Lucke
noreply at git.blender.org
Tue Aug 11 13:32:17 CEST 2020
Commit: e11aa3edddf54b451645b5f32775559b5af7ee1a
Author: Jacques Lucke
Date: Tue Aug 11 13:32:07 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rBe11aa3edddf54b451645b5f32775559b5af7ee1a
Python: don't remove existing context overrides when calling an operator
Reviewers: campbellbarton, brecht
Differential Revision: https://developer.blender.org/D8532
===================================================================
M source/blender/python/intern/bpy_operator.c
===================================================================
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) {
More information about the Bf-blender-cvs
mailing list