diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-15 13:49:38 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-15 14:02:44 +0300 |
commit | 3f20105622a9871e6b71e8a29b25e24a97202e38 (patch) | |
tree | 932106a3def9b36ce4d5acebd99231168294c1ee /source/blender/editors/space_outliner | |
parent | 8021ac986a6437b6013a22d98e54186592f5d285 (diff) |
Fix random crashes in the outliner, especially with bigger scenes.
The outliner can redraw quicker without rebuilding the tree, for example when
just moving the mouse and highlighting different items. The way this worked is
that the outliner would be tagged to avoid rebuilding, however if another
operation that does require rebuilding happens in the meantime we could go out
of sync and crash.
Diffstat (limited to 'source/blender/editors/space_outliner')
7 files changed, 22 insertions, 29 deletions
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index 1cfe5b16fe1..4ea2c243365 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -782,7 +782,6 @@ static int collection_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* TODO(sergey): Use proper flag for tagging here. */ DEG_id_tag_update(&scene->id, 0); - soops->storeflag |= SO_TREESTORE_REDRAW; WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 5d981bdad0d..c8765c5016e 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1987,7 +1987,4 @@ void draw_outliner(const bContext *C) UI_block_end(C, block); UI_block_draw(C, block); - - /* clear flag that allows quick redraws */ - soops->storeflag &= ~SO_TREESTORE_REDRAW; } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 9207ee5ae15..4733b09da2f 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -172,8 +172,7 @@ static int outliner_highlight_update(bContext *C, wmOperator *UNUSED(op), const } if (changed) { - soops->storeflag |= SO_TREESTORE_REDRAW; /* only needs to redraw, no rebuild */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw_no_rebuild(ar); } return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH); @@ -903,10 +902,8 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) else outliner_set_flag(&soops->tree, TSE_SELECTED, 1); - soops->storeflag |= SO_TREESTORE_REDRAW; - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - ED_region_tag_redraw(ar); + ED_region_tag_redraw_no_rebuild(ar); return OPERATOR_FINISHED; } @@ -1027,11 +1024,9 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) xdelta = (int)(te->xs - v2d->cur.xmin); v2d->cur.xmin += xdelta; v2d->cur.xmax += xdelta; - - so->storeflag |= SO_TREESTORE_REDRAW; } - ED_region_tag_redraw(ar); + ED_region_tag_redraw_no_rebuild(ar); return OPERATOR_FINISHED; } @@ -1187,7 +1182,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so soops->search_flags = flags; /* redraw */ - soops->storeflag |= SO_TREESTORE_REDRAW; + ED_region_tag_redraw_no_rebuild(ar); } } else { diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 2c4670d9ea3..9f466d331f3 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -271,11 +271,13 @@ static int outliner_item_drag_drop_modal(bContext *C, wmOperator *op, const wmEv break; } - if (skip_rebuild) { - soops->storeflag |= SO_TREESTORE_REDRAW; /* only needs to redraw, no rebuild */ - } if (redraw) { - ED_region_tag_redraw(ar); + if (skip_rebuild) { + ED_region_tag_redraw_no_rebuild(ar); + } + else { + ED_region_tag_redraw(ar); + } } return retval; @@ -389,8 +391,7 @@ static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *op, const wmE /* unset highlighted tree element, dragged one will be highlighted instead */ outliner_set_flag(&soops->tree, TSE_HIGHLIGHTED, false); - soops->storeflag |= SO_TREESTORE_REDRAW; /* only needs to redraw, no rebuild */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw_no_rebuild(ar); WM_event_add_modal_handler(C, op); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index b966b0f3dfa..4bde67d9662 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -995,12 +995,13 @@ int outliner_item_do_activate_from_cursor( } if (changed) { - if (!rebuild_tree) { - /* only needs to redraw, no rebuild */ - soops->storeflag |= SO_TREESTORE_REDRAW; + if (rebuild_tree) { + ED_region_tag_redraw(ar); + } + else { + ED_region_tag_redraw_no_rebuild(ar); } ED_undo_push(C, "Outliner selection change"); - ED_region_tag_redraw(ar); } return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index fff1bafdfff..fd5f29aec39 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -2034,9 +2034,10 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop outliner_set_flag(&soops->tree, TSE_SELECTED, 0); tselem->flag |= TSE_SELECTED; - /* redraw, same as outliner_select function */ - soops->storeflag |= SO_TREESTORE_REDRAW; - ED_region_tag_redraw(ar); + + /* Only redraw, don't rebuild here because TreeElement pointers will + * become invalid and operations will crash. */ + ED_region_tag_redraw_no_rebuild(ar); } set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index d1195621138..f8158c9ce7b 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1705,8 +1705,6 @@ static void outliner_restore_scrolling_position(SpaceOops *soops, ARegion *ar, O else { return; } - - soops->storeflag |= SO_TREESTORE_REDRAW; } } @@ -2070,8 +2068,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa BKE_outliner_treehash_rebuild_from_treestore(soops->treehash, soops->treestore); } - if (soops->tree.first && (soops->storeflag & SO_TREESTORE_REDRAW)) + if (ar->flag & RGN_DRAW_NO_REBUILD) { return; + } OutlinerTreeElementFocus focus; outliner_store_scrolling_position(soops, ar, &focus); |