Fix T55945: Outliner crash

crashed when using filtering and no item was found ('Blender File' mode)

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D3535
This commit is contained in:
Philipp Oeser 2018-07-12 13:37:29 +02:00
parent 98c215f4db
commit c21488df5a
Notes: blender-bot 2023-02-14 10:37:50 +01:00
Referenced by issue #55945, Outliner / blender file -autocrash
1 changed files with 21 additions and 19 deletions

View File

@ -2160,28 +2160,30 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
}
/* make hierarchy */
ten = soops->tree.first;
ten = ten->next; /* first one is main */
while (ten) {
TreeElement *nten = ten->next, *par;
tselem = TREESTORE(ten);
lib = (Library *)tselem->id;
if (lib && lib->parent) {
par = (TreeElement *)lib->parent->id.newid;
if (tselem->id->tag & LIB_TAG_INDIRECT) {
/* Only remove from 'first level' if lib is not also directly used. */
BLI_remlink(&soops->tree, ten);
BLI_addtail(&par->subtree, ten);
ten->parent = par;
}
else {
/* Else, make a new copy of the libtree for our parent. */
TreeElement *dupten = outliner_add_library_contents(mainvar, soops, &par->subtree, lib);
if (dupten) {
dupten->parent = par;
if (ten != NULL) {
ten = ten->next; /* first one is main */
while (ten) {
TreeElement *nten = ten->next, *par;
tselem = TREESTORE(ten);
lib = (Library *)tselem->id;
if (lib && lib->parent) {
par = (TreeElement *)lib->parent->id.newid;
if (tselem->id->tag & LIB_TAG_INDIRECT) {
/* Only remove from 'first level' if lib is not also directly used. */
BLI_remlink(&soops->tree, ten);
BLI_addtail(&par->subtree, ten);
ten->parent = par;
}
else {
/* Else, make a new copy of the libtree for our parent. */
TreeElement *dupten = outliner_add_library_contents(mainvar, soops, &par->subtree, lib);
if (dupten) {
dupten->parent = par;
}
}
}
ten = nten;
}
ten = nten;
}
/* restore newid pointers */
for (lib = mainvar->library.first; lib; lib = lib->id.next)