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:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user