Fix T87090: VSE scrubbing locks up blender

Speed effect caused, that some raw frames are re-used for multiple
final frames. When cached final frame is freed due to memory being
full, it tried to free also lower level cached frames that were used
during compositing. Some lower level cached frames were already freed
by different final frame and `BLI_ghash_remove()` failed.

Check if key still exists in hash or if linked keys were overwritten
before removing them.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D10909
This commit is contained in:
Richard Antalik 2021-04-22 14:09:33 +02:00
parent 71db02ed88
commit 0ba0d27d36
Notes: blender-bot 2023-02-14 06:37:09 +01:00
Referenced by issue #87090, VSE scrubbing locks up blender
1 changed files with 20 additions and 0 deletions

View File

@ -976,14 +976,34 @@ static void seq_cache_recycle_linked(Scene *scene, SeqCacheKey *base)
SeqCacheKey *next = base->link_next;
while (base) {
if (!BLI_ghash_haskey(cache->hash, base)) {
break; /* Key has already been removed from cache. */
}
SeqCacheKey *prev = base->link_prev;
if (prev != NULL && prev->link_next != base) {
/* Key has been removed and replaced and doesn't belong to this chain anymore. */
base->link_prev = NULL;
break;
}
BLI_ghash_remove(cache->hash, base, seq_cache_keyfree, seq_cache_valfree);
base = prev;
}
base = next;
while (base) {
if (!BLI_ghash_haskey(cache->hash, base)) {
break; /* Key has already been removed from cache. */
}
next = base->link_next;
if (next != NULL && next->link_prev != base) {
/* Key has been removed and replaced and doesn't belong to this chain anymore. */
base->link_next = NULL;
break;
}
BLI_ghash_remove(cache->hash, base, seq_cache_keyfree, seq_cache_valfree);
base = next;
}