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 <mont29>2022-04-06 11:48:33 +0300
committerBastien Montagne <bastien@blender.org>2022-04-06 12:37:15 +0300
commite06399c223686aee7c2b6f9fb2db66a5f2cffad6 (patch)
tree15779f9dd3a1cdd312c16e96db7f924aa20606ae /source/blender/blenkernel/intern/image.cc
parent8dd3387eb74566f6c52d5c83f22a8e89a908df2a (diff)
Fix badly broken caches handling during undo/redo.
Original rework of caches during undo/redo (see D8183) had a very bad flaw hidden in it: using the key of a ghash as source of data. While this was effectively working then (cache pointer itself being part of the key, and said cache pointers not being cleared on file write), this is a general very bad way to do things. Now that cache pointers are more and more cleared on file write (as part of clearing runtime-data to reduce false-positives when checking if an ID has changed or not), this has to be fixed properly by: * Not storing the cache pointer itself in the IDCacheKey. * In undo context, in readfile code trying to preserve caches, store the cache pointers as values of the mapping, together with the usages counter The first change potentially affects all usages of `BKE_idtype_id_foreach_cache`, but in practice this code is only used by memfile reading code (i.e. undo) currently. Related to T97015. Reviewed By: brecht Maniphest Tasks: T97015 Differential Revision: https://developer.blender.org/D14559
Diffstat (limited to 'source/blender/blenkernel/intern/image.cc')
-rw-r--r--source/blender/blenkernel/intern/image.cc4
1 files changed, 0 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc
index 3eade265bf2..b1385eab9cf 100644
--- a/source/blender/blenkernel/intern/image.cc
+++ b/source/blender/blenkernel/intern/image.cc
@@ -234,7 +234,6 @@ static void image_foreach_cache(ID *id,
IDCacheKey key;
key.id_session_uuid = id->session_uuid;
key.offset_in_ID = offsetof(Image, cache);
- key.cache_v = image->cache;
function_callback(id, &key, (void **)&image->cache, 0, user_data);
auto gputexture_offset = [image](int target, int eye, int resolution) {
@@ -253,19 +252,16 @@ static void image_foreach_cache(ID *id,
continue;
}
key.offset_in_ID = gputexture_offset(a, eye, resolution);
- key.cache_v = texture;
function_callback(id, &key, (void **)&image->gputexture[a][eye][resolution], 0, user_data);
}
}
}
key.offset_in_ID = offsetof(Image, rr);
- key.cache_v = image->rr;
function_callback(id, &key, (void **)&image->rr, 0, user_data);
LISTBASE_FOREACH (RenderSlot *, slot, &image->renderslots) {
key.offset_in_ID = (size_t)BLI_ghashutil_strhash_p(slot->name);
- key.cache_v = slot->render;
function_callback(id, &key, (void **)&slot->render, 0, user_data);
}
}