BKE_reports: make the API thread-safe.
This commit makes using (most of) `BKE_report` API safe in
multi-threaded situation.
This is achieved by adding a `std::mutex` lock to the `ReportList`
struct (in a slightly convoluted way unfortunately, due to this being a
DNA struct). This lock is then used to make most operations on
`Reportlist` data thread-safe.
Note that while working on this, a few other minor issues aroze in
existing usages of Reportlist by the WM code, mainly the fact that
`wm_init_reports` and `wm_free_reports` were both useless:
- init was called in a context where there is not yet any WM, so it
was doing nothing.
- free was called on a WM that would be later freed (as part of Main
freeing), which would also call cleanup code for its `reports` data.
Both have been removed.
Further more, `wm_add_default` (which is the only place where a WM ID is
created) did not initialize properly it reports data, this has been
fixed.
This change is related to the wmJob thread-safety tasks and PRs (#112537,
!113548).
Pull Request: https://projects.blender.org/blender/blender/pulls/113561
This commit is contained in:
committed by
Bastien Montagne
parent
db2328436e
commit
9859622a66
@@ -187,17 +187,18 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject *
|
||||
|
||||
if (retval) {
|
||||
BKE_reports_print(&reports, RPT_ERROR_ALL);
|
||||
BKE_reports_clear(&reports);
|
||||
ret = Py_None;
|
||||
Py_INCREF(ret);
|
||||
}
|
||||
else {
|
||||
if (BPy_reports_to_error(&reports, PyExc_IOError, true) == 0) {
|
||||
if (BPy_reports_to_error(&reports, PyExc_IOError, false) == 0) {
|
||||
PyErr_SetString(PyExc_IOError, "Unknown error writing library data");
|
||||
}
|
||||
ret = nullptr;
|
||||
}
|
||||
|
||||
BKE_reports_free(&reports);
|
||||
|
||||
finally:
|
||||
|
||||
/* clear all flags for ID's added to the store (may run on error too) */
|
||||
|
||||
Reference in New Issue
Block a user