[Bf-blender-cvs] [fc9c39e320a] master: Fix T103242: Missing update on undo/redo for some image properties.

Bastien Montagne noreply at git.blender.org
Fri Jan 6 11:31:49 CET 2023


Commit: fc9c39e320a87f40473b077f96be4472f53e98b5
Author: Bastien Montagne
Date:   Fri Jan 6 11:01:11 2023 +0100
Branches: master
https://developer.blender.org/rBfc9c39e320a87f40473b077f96be4472f53e98b5

Fix T103242: Missing update on undo/redo for some image properties.

Issue comes from the fact that some of the image updates are handled
outside of depsgraph context (through the signal system), and therefore
completely ignored by the undo/redo code.

Now that undo/redo tries to update as little data as possible, it needs
to be aware of these changes.

As a temporary workaround, until image update is fully handled through depsgraph,
consider that IDs tagged with `ID_RECALC_SOURCE` should get their caches
cleared on undo/redo, and tag some RNA property updates of
Image/ColorSpace as such.

Reviewed By: sergey

Maniphest Tasks: T103242

Differential Revision: https://developer.blender.org/D16927

===================================================================

M	source/blender/blenloader/intern/readfile.cc
M	source/blender/makesrna/intern/rna_color.c
M	source/blender/makesrna/intern/rna_image.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc
index 953beee6fbd..ed88495797d 100644
--- a/source/blender/blenloader/intern/readfile.cc
+++ b/source/blender/blenloader/intern/readfile.cc
@@ -1604,7 +1604,7 @@ static void blo_cache_storage_entry_register(
 
 /** Restore a cache data entry from old ID into new one, when reading some undo memfile. */
 static void blo_cache_storage_entry_restore_in_new(
-    ID * /*id*/, const IDCacheKey *key, void **cache_p, uint flags, void *cache_storage_v)
+    ID *id, const IDCacheKey *key, void **cache_p, uint flags, void *cache_storage_v)
 {
   BLOCacheStorage *cache_storage = static_cast<BLOCacheStorage *>(cache_storage_v);
 
@@ -1618,6 +1618,15 @@ static void blo_cache_storage_entry_restore_in_new(
     return;
   }
 
+  /* Assume that when ID source is tagged as changed, its caches need to be cleared.
+   * NOTE: This is mainly a work-around for some IDs, like Image, which use a non-depsgraph-handled
+   * process for part of their updates.
+   */
+  if (id->recalc & ID_RECALC_SOURCE) {
+    *cache_p = nullptr;
+    return;
+  }
+
   BLOCacheStorageValue *storage_value = static_cast<BLOCacheStorageValue *>(
       BLI_ghash_lookup(cache_storage->cache_map, key));
   if (storage_value == nullptr) {
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index acc1efe8d12..72cf9d57c7b 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -626,6 +626,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
     Image *ima = (Image *)id;
 
     DEG_id_tag_update(&ima->id, 0);
+    DEG_id_tag_update(&ima->id, ID_RECALC_SOURCE);
 
     BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
 
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 9deb8a1c90b..97233f39d86 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -194,7 +194,7 @@ static void rna_Image_colormanage_update(Main *bmain, Scene *UNUSED(scene), Poin
   Image *ima = (Image *)ptr->owner_id;
   BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
   DEG_id_tag_update(&ima->id, 0);
-  DEG_id_tag_update(&ima->id, ID_RECALC_EDITORS);
+  DEG_id_tag_update(&ima->id, ID_RECALC_EDITORS | ID_RECALC_SOURCE);
   WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
   WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
 }



More information about the Bf-blender-cvs mailing list