[Bf-blender-cvs] [9be6880d020] blender-v3.0-release: Fix (unreported) bad handling of reports in `libraries.load` code.
Bastien Montagne
noreply at git.blender.org
Thu Nov 11 14:33:14 CET 2021
Commit: 9be6880d020eb2a6891c07e0b8794400f20f5464
Author: Bastien Montagne
Date: Thu Nov 11 14:29:14 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rB9be6880d020eb2a6891c07e0b8794400f20f5464
Fix (unreported) bad handling of reports in `libraries.load` code.
rB60fee69682ac39 only partially fixed the issue, `BlendFileReadReport
bf_reports` was now properly stored in `BPy_Library` `self` for the
lifetime of the context, but its `reports` member was still referencing
local variable to `bpy_lib_enter` function.
===================================================================
M source/blender/python/intern/bpy_library_load.c
===================================================================
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index d9a357c5e2e..059d692a9ba 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -67,7 +67,9 @@ typedef struct {
char abspath[FILE_MAX]; /* absolute path */
BlendHandle *blo_handle;
/* Referenced by `blo_handle`, so stored here to keep alive for long enough. */
+ ReportList reports;
BlendFileReadReport bf_reports;
+
int flag;
PyObject *dict;
/* Borrowed reference to the `bmain`, taken from the RNA instance of #RNA_BlendDataLibraries.
@@ -256,16 +258,17 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
PyObject *ret;
BPy_Library *self_from;
PyObject *from_dict = _PyDict_NewPresized(INDEX_ID_MAX);
- ReportList reports;
+ ReportList *reports = &self->reports;
+ BlendFileReadReport *bf_reports = &self->bf_reports;
- BKE_reports_init(&reports, RPT_STORE);
- BlendFileReadReport bf_reports = {.reports = &reports};
+ BKE_reports_init(reports, RPT_STORE);
+ memset(bf_reports, 0, sizeof(*bf_reports));
+ bf_reports->reports = reports;
- self->bf_reports = bf_reports;
- self->blo_handle = BLO_blendhandle_from_file(self->abspath, &self->bf_reports);
+ self->blo_handle = BLO_blendhandle_from_file(self->abspath, bf_reports);
if (self->blo_handle == NULL) {
- if (BPy_reports_to_error(&reports, PyExc_IOError, true) != -1) {
+ if (BPy_reports_to_error(reports, PyExc_IOError, true) != -1) {
PyErr_Format(PyExc_IOError, "load: %s failed to open blend file", self->abspath);
}
return NULL;
@@ -301,7 +304,7 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
PyTuple_SET_ITEMS(ret, (PyObject *)self_from, (PyObject *)self);
Py_INCREF(self);
- BKE_reports_clear(&reports);
+ BKE_reports_clear(reports);
return ret;
}
More information about the Bf-blender-cvs
mailing list