Python: don't remove existing context overrides when calling an operator

Reviewers: campbellbarton, brecht

Differential Revision: https://developer.blender.org/D8532
This commit is contained in:
Jacques Lucke 2020-08-11 13:32:07 +02:00
parent 6d888133da
commit e11aa3eddd
1 changed files with 8 additions and 1 deletions

View File

@ -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) {