Fix #114237: USD import crashes on reporting during cache handling.

This usage of the whole USD `USDStageReader` as 'cache handle' feels a
bit... uncomfortable to me. It implicitely assumes that all data in this
owned by the reader (or has a lifetime that contains the whole handle
lifetime). IMHO, if such struct is expected to have a long lifetime, it
should be documented, and probably needs better design for sub-data
handling then. Am curious to know if there is a good reason why the
handle itself is not a simple trivial class, able to re-generate an
actual complete USD reader on demand?

Or maybe we need to find a better place to store the `wmJobWorkerStatus`
data?

Anyway, for now this PR addresses the issue by ensuring that the
`worker_status` stored in the `USDImportParams` is not `nullptr` before
trying to access it for the reports.

This is more of a short-term solution though, imho there should be a way
to pass a reportlist to this codepath, and ensure the `wmJobWorkerStatus`
is always valid?

Pull Request: https://projects.blender.org/blender/blender/pulls/114337
This commit is contained in:
Bastien Montagne
2023-10-31 19:28:56 +01:00
committed by Gitea
parent 1500a594ad
commit 730b5057a7
3 changed files with 3 additions and 3 deletions

View File

@@ -91,7 +91,7 @@ class USDMaterialReader {
/** Get the wmJobWorkerStatus-provided `reports` list pointer, to use with the BKE_report API. */
ReportList *reports() const
{
return params_.worker_status->reports;
return params_.worker_status ? params_.worker_status->reports : nullptr;
}
protected:

View File

@@ -122,7 +122,7 @@ class USDPrimReader {
/** Get the wmJobWorkerStatus-provided `reports` list pointer, to use with the BKE_report API. */
ReportList *reports() const
{
return import_params_.worker_status->reports;
return import_params_.worker_status ? import_params_.worker_status->reports : nullptr;
}
/* Since readers might be referenced through handles

View File

@@ -84,7 +84,7 @@ class USDStageReader {
/** Get the wmJobWorkerStatus-provided `reports` list pointer, to use with the BKE_report API. */
ReportList *reports() const
{
return params_.worker_status->reports;
return params_.worker_status ? params_.worker_status->reports : nullptr;
}
void clear_readers();