[Bf-blender-cvs] [9e33636] gooseberry: Take NULL object pointers in cache items into account.

Lukas Tönne noreply at git.blender.org
Mon Mar 23 13:01:28 CET 2015


Commit: 9e336362d8af3860b3c7e6e94c4a3ed037222cf7
Author: Lukas Tönne
Date:   Wed Feb 25 16:59:51 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB9e336362d8af3860b3c7e6e94c4a3ed037222cf7

Take NULL object pointers in cache items into account.

This can happen if an object gets deleted or isn't loaded for some
reason. The item should just be ignored in that case and removed at the
next opportunity (cleanup function).

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

M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/pointcache/PTC_api.cpp

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

diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 7a02897..2a4956f 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -302,7 +302,8 @@ static unsigned int cache_item_hash(const void *key)
 	
 	hash = BLI_ghashutil_inthash(item->type);
 	
-	hash = hash_int_2d(hash, BLI_ghashutil_ptrhash(item->ob));
+	if (item->ob)
+		hash = hash_int_2d(hash, BLI_ghashutil_ptrhash(item->ob));
 	if (item->index >= 0)
 		hash = hash_int_2d(hash, BLI_ghashutil_inthash(item->index));
 	
@@ -458,9 +459,7 @@ void BKE_cache_library_group_update(Main *bmain, CacheLibrary *cachelib)
 		for (item = cachelib->items.first; item; item = item_next) {
 			item_next = item->next;
 			
-			BLI_assert(item->ob != NULL);
-			
-			if (!(item->ob->id.flag & LIB_DOIT)) {
+			if (!item->ob || !(item->ob->id.flag & LIB_DOIT)) {
 				BKE_cache_library_remove_item(cachelib, item);
 			}
 		}
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index a5155a2..b57aa74 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -367,7 +367,7 @@ PTCWriterArchive *PTC_cachelib_writers(Scene *scene, CacheLibrary *cachelib, Lis
 	for (CacheItem *item = (CacheItem *)cachelib->items.first; item; item = item->next) {
 		char name[2*MAX_NAME];
 		
-		if (!(item->flag & CACHE_ITEM_ENABLED))
+		if (!item->ob || !(item->flag & CACHE_ITEM_ENABLED))
 			continue;
 		
 		BKE_cache_item_name(item->ob, item->type, item->index, name);




More information about the Bf-blender-cvs mailing list