Fix #147565: Prevent viewlayer resync during threaded liboverride process.
Code executing in parallelized context should never attempt to resync viewlayers, this is just not safe. So instead, explicitly call `BKE_main_view_layers_synced_ensure` and forbid further updates before entering the multi-threaded part of `BKE_lib_override_library_main_operations_create`. This should make issues like #147565 less likely to happen in the future.
This commit is contained in:
@@ -4787,6 +4787,13 @@ void BKE_lib_override_library_main_operations_create(Main *bmain,
|
||||
BKE_pose_ensure(bmain, ob, static_cast<bArmature *>(ob->data), true);
|
||||
}
|
||||
}
|
||||
/* Similar issue with view layers, some may not be up-to-date, and re-syncing them from a
|
||||
* multi-threaded process is utterly unsafe. Some RNA property access may cause this, see e.g.
|
||||
* #147565 and the `node_warnings` property of the Geometry Nodes. */
|
||||
const bool resync_success = BKE_main_view_layers_synced_ensure(bmain);
|
||||
BLI_assert_msg(resync_success,
|
||||
"Ensuring that all viewlayers in Main are synced with their collections failed");
|
||||
BKE_layer_collection_resync_forbid();
|
||||
|
||||
LibOverrideOpCreateData create_pool_data{};
|
||||
create_pool_data.bmain = bmain;
|
||||
@@ -4855,6 +4862,8 @@ void BKE_lib_override_library_main_operations_create(Main *bmain,
|
||||
|
||||
BLI_task_pool_free(task_pool);
|
||||
|
||||
BKE_layer_collection_resync_allow();
|
||||
|
||||
if (create_pool_data.report_flags & RNA_OVERRIDE_MATCH_RESULT_RESTORE_TAGGED) {
|
||||
BKE_lib_override_library_main_operations_restore(
|
||||
bmain, reinterpret_cast<int *>(&create_pool_data.report_flags));
|
||||
|
||||
Reference in New Issue
Block a user