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:
parent
aa8e058a59
commit
a54253f335
|
@ -85,10 +85,12 @@ bool BKE_lib_override_library_resync(struct Main *bmain,
|
|||
struct ID *id_root,
|
||||
struct Collection *override_resync_residual_storage,
|
||||
const bool do_hierarchy_enforce,
|
||||
const bool do_post_process);
|
||||
const bool do_post_process,
|
||||
struct ReportList *reports);
|
||||
void BKE_lib_override_library_main_resync(struct Main *bmain,
|
||||
struct Scene *scene,
|
||||
struct ViewLayer *view_layer);
|
||||
struct ViewLayer *view_layer,
|
||||
struct ReportList *reports);
|
||||
|
||||
void BKE_lib_override_library_delete(struct Main *bmain, struct ID *id_root);
|
||||
|
||||
|
|
|
@ -399,7 +399,8 @@ static void setup_app_data(bContext *C,
|
|||
BKE_lib_override_library_main_resync(
|
||||
bmain,
|
||||
curscene,
|
||||
bfd->cur_view_layer ? bfd->cur_view_layer : BKE_view_layer_default_view(curscene));
|
||||
bfd->cur_view_layer ? bfd->cur_view_layer : BKE_view_layer_default_view(curscene),
|
||||
reports);
|
||||
/* We need to rebuild some of the deleted override rules (for UI feedback purpose). */
|
||||
BKE_lib_override_library_main_operations_create(bmain, true);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -902,7 +902,7 @@ static void id_override_library_reset_fn(bContext *C,
|
|||
}
|
||||
|
||||
static void id_override_library_resync_fn(bContext *C,
|
||||
ReportList *UNUSED(reports),
|
||||
ReportList *reports,
|
||||
Scene *scene,
|
||||
TreeElement *te,
|
||||
TreeStoreElem *UNUSED(tsep),
|
||||
|
@ -931,7 +931,7 @@ static void id_override_library_resync_fn(bContext *C,
|
|||
}
|
||||
|
||||
BKE_lib_override_library_resync(
|
||||
bmain, scene, CTX_data_view_layer(C), id_root, NULL, do_hierarchy_enforce, true);
|
||||
bmain, scene, CTX_data_view_layer(C), id_root, NULL, do_hierarchy_enforce, true, reports);
|
||||
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue