LibOverride: Add proper reports when deleting user-edited overrides as part of resync.

Logs are not enough here, we need proper warning visible for the user.
This commit is contained in:
2021-05-06 19:04:47 +02:00
parent aa8e058a59
commit a54253f335
4 changed files with 26 additions and 8 deletions

View File

@@ -878,7 +878,8 @@ bool BKE_lib_override_library_resync(Main *bmain,
ID *id_root,
Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce,
const bool do_post_process)
const bool do_post_process,
ReportList *reports)
{
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root));
BLI_assert(!ID_IS_LINKED(id_root));
@@ -1044,6 +1045,7 @@ bool BKE_lib_override_library_resync(Main *bmain,
/* Delete old override IDs.
* Note that we have to use tagged group deletion here, since ID deletion also uses LIB_TAG_DOIT.
* This improves performances anyway, so everything is fine. */
int user_edited_overrides_deletion_count = 0;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (id->tag & LIB_TAG_DOIT) {
/* Note that this works because linked IDs are always after local ones (including overrides),
@@ -1084,6 +1086,7 @@ bool BKE_lib_override_library_resync(Main *bmain,
id->tag &= ~LIB_TAG_MISSING;
CLOG_WARN(
&LOG, "Old override %s is being deleted even though it was user-edited", id->name);
user_edited_overrides_deletion_count++;
}
#endif
}
@@ -1096,6 +1099,15 @@ bool BKE_lib_override_library_resync(Main *bmain,
*/
id_root = id_root_reference->newid;
if (user_edited_overrides_deletion_count > 0) {
BKE_reportf(reports,
RPT_WARNING,
"During resync of data-block %s, %d obsolete overrides were deleted, that had "
"local changes defined by user",
id_root->name + 2,
user_edited_overrides_deletion_count);
}
if (do_post_process) {
/* Essentially ensures that potentially new overrides of new objects will be instantiated. */
/* Note: Here 'reference' collection and 'newly added' collection are the same, which is fine
@@ -1134,7 +1146,10 @@ bool BKE_lib_override_library_resync(Main *bmain,
* Then it will handle the resync of necessary IDs (through calls to
* #BKE_lib_override_library_resync).
*/
void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *view_layer)
void BKE_lib_override_library_main_resync(Main *bmain,
Scene *scene,
ViewLayer *view_layer,
ReportList *reports)
{
/* We use a specific collection to gather/store all 'orphaned' override collections and objects
* generated by re-sync-process. This avoids putting them in scene's master collection. */
@@ -1250,7 +1265,7 @@ void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *
CLOG_INFO(&LOG, 2, "Resyncing %s...", id->name);
const bool success = BKE_lib_override_library_resync(
bmain, scene, view_layer, id, override_resync_residual_storage, false, false);
bmain, scene, view_layer, id, override_resync_residual_storage, false, false, reports);
CLOG_INFO(&LOG, 2, "\tSuccess: %d", success);
break;
}