diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-05-15 16:52:24 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-05-15 20:29:18 +0300 |
commit | 2d479421af7ea75d7f005aabaa909880043dbace (patch) | |
tree | 37a14bbc2c1c46d0d6f80c500da96cd8e4a9b5f8 | |
parent | 5dc22fbbfbed0e825faa8faab8bc5f32a6fdd829 (diff) |
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!
-rw-r--r-- | source/blender/blenkernel/intern/outliner_treehash.c | 22 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tree.c | 2 |
2 files changed, 21 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/outliner_treehash.c b/source/blender/blenkernel/intern/outliner_treehash.c index 21664bfd285..f31ba34a984 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 728a7501d5b..d4bef06cca9 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); } |