From 31d762c3a80da99afa4e3ba6dd308746011de6cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Jul 2019 16:25:54 +1000 Subject: [PATCH] Fix T66356: runtime assert disabling a collection --- source/blender/editors/include/ED_object.h | 3 +++ source/blender/editors/object/object_select.c | 19 ++++++++++++++----- source/blender/makesrna/intern/rna_layer.c | 9 ++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index a4c68c2c5ad..038f1bf52a6 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -121,6 +121,9 @@ void ED_object_parent_clear(struct Object *ob, const int type); void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode); void ED_object_base_activate(struct bContext *C, struct Base *base); +void ED_object_base_active_refresh(struct Main *bmain, + struct Scene *scene, + struct ViewLayer *view_layer); void ED_object_base_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Object *ob); bool ED_object_base_deselect_all_ex(struct ViewLayer *view_layer, struct View3D *v3d, diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index fcba69f7e5d..da06707ebac 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -118,19 +118,28 @@ void ED_object_base_select(Base *base, eObjectSelect_Mode mode) } } +/** + * Call when the active base has changed. + */ +void ED_object_base_active_refresh(Main *bmain, Scene *scene, ViewLayer *view_layer) +{ + WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene); + DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); + struct wmMsgBus *mbus = ((wmWindowManager *)bmain->wm.first)->message_bus; + if (mbus != NULL) { + WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active); + } +} + /** * Change active base, it includes the notifier */ void ED_object_base_activate(bContext *C, Base *base) { - struct wmMsgBus *mbus = CTX_wm_message_bus(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); view_layer->basact = base; - - WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); - WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active); - DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); + ED_object_base_active_refresh(CTX_data_main(C), scene, view_layer); } bool ED_object_base_deselect_all_ex(ViewLayer *view_layer, diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index be7985b69a4..1c0ced060d5 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -278,15 +278,18 @@ static void rna_LayerCollection_exclude_update(Main *bmain, Scene *UNUSED(scene) LayerCollection *lc = (LayerCollection *)ptr->data; ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc); - /* Set/Unset it recursively to match the behaviour of excluding via the menu or shortcuts. */ - rna_LayerCollection_exclude_update_recursive(&lc->layer_collections, - (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0); + /* Set/Unset it recursively to match the behavior of excluding via the menu or shortcuts. */ + const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0; + rna_LayerCollection_exclude_update_recursive(&lc->layer_collections, exclude); BKE_layer_collection_sync(scene, view_layer); DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL); + if (exclude) { + ED_object_base_active_refresh(bmain, scene, view_layer); + } } static void rna_LayerCollection_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)