LibOverrides: small refactor of resync main public function.

Simplify signature of `BKE_lib_override_library_resync` and make it a
shallow wrapper around new internal `lib_override_library_resync` that
can then be easily extended for other internal needs.

Not functional changes expected here.
This commit is contained in:
Bastien Montagne
2022-01-07 15:25:25 +01:00
parent 5560f32447
commit b7ea6e9d0e
3 changed files with 31 additions and 13 deletions

View File

@@ -164,9 +164,9 @@ void BKE_lib_override_library_main_proxy_convert(struct Main *bmain,
* Advanced 'smart' function to resync, re-create fully functional overrides up-to-date with linked
* data, from an existing override hierarchy.
*
* \param id_root: The root liboverride ID to resync from.
* \param view_layer: the active view layer to search instantiated collections in, can be NULL (in
* which case \a scene's master collection children hierarchy is used instead).
* \param id_root: The root liboverride ID to resync from.
* \return true if override was successfully resynced.
*/
bool BKE_lib_override_library_resync(struct Main *bmain,
@@ -175,7 +175,6 @@ bool BKE_lib_override_library_resync(struct Main *bmain,
struct ID *id_root,
struct Collection *override_resync_residual_storage,
bool do_hierarchy_enforce,
bool do_post_process,
struct BlendFileReadReport *reports);
/**
* Detect and handle required resync of overrides data, when relations between reference linked IDs

View File

@@ -376,7 +376,6 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain,
* existing linked IDs usages. */
if (success) {
for (todo_id_iter = todo_ids.first; todo_id_iter != NULL; todo_id_iter = todo_id_iter->next) {
ID *other_id;
reference_id = todo_id_iter->data;
ID *local_id = reference_id->newid;
@@ -394,6 +393,7 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain,
* remapped to use newly created overriding IDs, if needed. */
ID *id;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
ID *other_id;
/* In case we created new overrides as 'no main', they are not accessible directly in this
* loop, but we can get to them through their reference's `newid` pointer. */
if (do_no_main && id->lib == reference_id->lib && id->newid != NULL) {
@@ -1121,14 +1121,14 @@ void BKE_lib_override_library_main_proxy_convert(Main *bmain, BlendFileReadRepor
}
}
bool BKE_lib_override_library_resync(Main *bmain,
Scene *scene,
ViewLayer *view_layer,
ID *id_root,
Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce,
const bool do_post_process,
BlendFileReadReport *reports)
static bool lib_override_library_resync(Main *bmain,
Scene *scene,
ViewLayer *view_layer,
ID *id_root,
Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce,
const bool do_post_process,
BlendFileReadReport *reports)
{
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root));
@@ -1499,6 +1499,26 @@ bool BKE_lib_override_library_resync(Main *bmain,
return success;
}
bool BKE_lib_override_library_resync(Main *bmain,
Scene *scene,
ViewLayer *view_layer,
ID *id_root,
Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce,
BlendFileReadReport *reports)
{
const bool success = lib_override_library_resync(bmain,
scene,
view_layer,
id_root,
override_resync_residual_storage,
do_hierarchy_enforce,
true,
reports);
return success;
}
/* Also tag ancestors overrides for resync.
*
* WARNING: Expects `bmain` to have valid relation data.
@@ -1763,7 +1783,7 @@ static void lib_override_library_main_resync_on_library_indirect_level(
do_continue = true;
CLOG_INFO(&LOG, 2, "Resyncing %s (%p)...", id->name, library);
const bool success = BKE_lib_override_library_resync(
const bool success = lib_override_library_resync(
bmain, scene, view_layer, id, override_resync_residual_storage, false, false, reports);
CLOG_INFO(&LOG, 2, "\tSuccess: %d", success);
if (success) {

View File

@@ -959,7 +959,6 @@ static void id_override_library_resync_fn(bContext *C,
id_root,
NULL,
do_hierarchy_enforce,
true,
&(struct BlendFileReadReport){.reports = reports});
WM_event_add_notifier(C, NC_WINDOW, NULL);