[Bf-blender-cvs] [2d47942] master: Fix crasher in new lazy-rebuild outliner's treehash.

Bastien Montagne noreply at git.blender.org
Fri May 15 19:29:33 CEST 2015


Commit: 2d479421af7ea75d7f005aabaa909880043dbace
Author: Bastien Montagne
Date:   Fri May 15 15:52:24 2015 +0200
Branches: master
https://developer.blender.org/rB2d479421af7ea75d7f005aabaa909880043dbace

Fix crasher in new lazy-rebuild outliner's treehash.

treehash must always been checked before used!

Reported on irc by sebastian_k and investigated by sergey, thanks!

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

M	source/blender/blenkernel/intern/outliner_treehash.c
M	source/blender/editors/space_outliner/outliner_tree.c

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

diff --git a/source/blender/blenkernel/intern/outliner_treehash.c b/source/blender/blenkernel/intern/outliner_treehash.c
index 21664bf..f31ba34 100644
--- a/source/blender/blenkernel/intern/outliner_treehash.c
+++ b/source/blender/blenkernel/intern/outliner_treehash.c
@@ -102,6 +102,9 @@ static void fill_treehash(void *treehash, BLI_mempool *treestore)
 	TreeStoreElem *tselem;
 	BLI_mempool_iter iter;
 	BLI_mempool_iternew(treestore, &iter);
+
+	BLI_assert(treehash);
+
 	while ((tselem = BLI_mempool_iterstep(&iter))) {
 		BKE_outliner_treehash_add_element(treehash, tselem);
 	}
@@ -121,6 +124,8 @@ static void free_treehash_group(void *key)
 
 void *BKE_outliner_treehash_rebuild_from_treestore(void *treehash, BLI_mempool *treestore)
 {
+	BLI_assert(treehash);
+
 	BLI_ghash_clear_ex(treehash, NULL, free_treehash_group, BLI_mempool_count(treestore));
 	fill_treehash(treehash, treestore);
 	return treehash;
@@ -144,12 +149,19 @@ static TseGroup *BKE_outliner_treehash_lookup_group(GHash *th, short type, short
 	tse_template.type = type;
 	tse_template.nr = type ? nr : 0;  // we're picky! :)
 	tse_template.id = id;
+
+	BLI_assert(th);
+
 	return BLI_ghash_lookup(th, &tse_template);
 }
 
 TreeStoreElem *BKE_outliner_treehash_lookup_unused(void *treehash, short type, short nr, struct ID *id)
 {
-	TseGroup *group = BKE_outliner_treehash_lookup_group(treehash, type, nr, id);
+	TseGroup *group;
+
+	BLI_assert(treehash);
+
+	group = BKE_outliner_treehash_lookup_group(treehash, type, nr, id);
 	if (group) {
 		int i;
 		for (i = 0; i < group->size; i++) {
@@ -163,11 +175,17 @@ TreeStoreElem *BKE_outliner_treehash_lookup_unused(void *treehash, short type, s
 
 TreeStoreElem *BKE_outliner_treehash_lookup_any(void *treehash, short type, short nr, struct ID *id)
 {
-	TseGroup *group = BKE_outliner_treehash_lookup_group(treehash, type, nr, id);
+	TseGroup *group;
+
+	BLI_assert(treehash);
+
+	group = BKE_outliner_treehash_lookup_group(treehash, type, nr, id);
 	return group ? group->elems[0] : NULL;
 }
 
 void BKE_outliner_treehash_free(void *treehash)
 {
+	BLI_assert(treehash);
+
 	BLI_ghash_free(treehash, NULL, free_treehash_group);
 }
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 728a750..d4bef06 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1580,7 +1580,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
 	else
 		soops->search_flags &= ~SO_SEARCH_RECURSIVE;
 
-	if (soops->storeflag & SO_TREESTORE_REBUILD) {
+	if (soops->treehash && (soops->storeflag & SO_TREESTORE_REBUILD)) {
 		soops->storeflag &= ~SO_TREESTORE_REBUILD;
 		BKE_outliner_treehash_rebuild_from_treestore(soops->treehash, soops->treestore);
 	}




More information about the Bf-blender-cvs mailing list