Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-12-31 20:03:45 +0300
committerBastien Montagne <bastien@blender.org>2021-03-11 16:26:19 +0300
commit534f4e90fd62dab3a19228219c69cb3f065c6f43 (patch)
tree0a0e723e8011c2a3b8be450a262a1e1724143c97 /source/blender/blenkernel
parent96064c3bb7d135ab69eb4a146c173dc4a36db1cc (diff)
LibOverride: First stage of detection of 'need resync'.
We can fairly easily detect some resync-needed cases when applying the overrides operations on a Pointer RNA property. This should cover all cases where an existing override's ID pointer is changed in its linked data. We still have to add code to detect when a not-yet-overridden linked ID needs to become overridden (because its relations to other data-blocks changed in a way that requires it). Part of T83811 & D10649.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/lib_override.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 95643773088..b9158697df9 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -909,6 +909,8 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
ID *id_override_new = id->newid;
ID *id_override_old = BLI_ghash_lookup(linkedref_to_old_override, id);
+ BLI_assert((id_override_new->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) == 0);
+
if (id_override_old != NULL) {
/* Swap the names between old override ID and new one. */
char id_name_buf[MAX_ID_NAME];
@@ -1920,6 +1922,14 @@ void BKE_lib_override_library_main_unused_cleanup(struct Main *bmain)
FOREACH_MAIN_ID_END;
}
+static void lib_override_id_swap(Main *bmain, ID *id_local, ID *id_temp)
+{
+ BKE_lib_id_swap(bmain, id_local, id_temp);
+ /* We need to keep these tags from temp ID into orig one.
+ * ID swap does not swap most of ID data itself. */
+ id_local->tag |= (id_temp->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC);
+}
+
/** Update given override from its reference (re-applying overridden properties). */
void BKE_lib_override_library_update(Main *bmain, ID *local)
{
@@ -1988,11 +1998,11 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
/* This also transfers all pointers (memory) owned by local to tmp_id, and vice-versa.
* So when we'll free tmp_id, we'll actually free old, outdated data from local. */
- BKE_lib_id_swap(bmain, local, tmp_id);
+ lib_override_id_swap(bmain, local, tmp_id);
if (local_key != NULL && tmp_key != NULL) {
/* This is some kind of hard-coded 'always enforced override'. */
- BKE_lib_id_swap(bmain, &local_key->id, &tmp_key->id);
+ lib_override_id_swap(bmain, &local_key->id, &tmp_key->id);
tmp_key->id.flag |= (local_key->id.flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE);
/* The swap of local and tmp_id inverted those pointers, we need to redefine proper
* relationships. */