Fix: Selection syncing for outliner operators

A few outliner operators that modify selection were not tagging for a
selection sync which led to selection inconsistencies. This adds syncing
for the following operators:
* Duplicating and deleting collections
* Selecting/deselecting collection contents
* Drag and drop
* Object select, deselect, delete, and delete hierarchy
This commit is contained in:
Nathan Craddock 2020-04-24 20:18:39 -06:00
parent a8441fc900
commit 5d14463e1a
Notes: blender-bot 2023-02-14 10:11:49 +01:00
Referenced by issue #74091, Select collection operator wont select them in outliner
Referenced by issue #71290, 2.81 Outliner: inconsistent selection and context menu
4 changed files with 19 additions and 8 deletions

View File

@ -377,6 +377,8 @@ static int collection_delete_exec(bContext *C, wmOperator *op)
WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active);
}
ED_outliner_select_sync_from_object_tag(C);
return OPERATOR_FINISHED;
}
@ -458,6 +460,7 @@ static int collection_objects_select_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
ED_outliner_select_sync_from_object_tag(C);
return OPERATOR_FINISHED;
}
@ -580,6 +583,7 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER, CTX_data_scene(C));
ED_outliner_select_sync_from_object_tag(C);
return OPERATOR_FINISHED;
}

View File

@ -982,6 +982,8 @@ static int outliner_item_drag_drop_invoke(bContext *C,
WM_drag_add_ID(drag, data.drag_id, data.drag_parent);
}
ED_outliner_select_sync_from_all_tag(C);
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
}

View File

@ -817,6 +817,7 @@ static int outliner_id_paste_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_WINDOW, NULL);
BKE_reportf(op->reports, RPT_INFO, "%d data-block(s) pasted", num_pasted);
return OPERATOR_FINISHED;
}

View File

@ -1354,6 +1354,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
SpaceOutliner *soops = CTX_wm_space_outliner(C);
int event;
const char *str = NULL;
bool selection_changed = false;
/* check for invalid states */
if (soops == NULL) {
@ -1370,8 +1371,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
}
str = "Select Objects";
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
selection_changed = true;
}
else if (event == OL_OP_SELECT_HIERARCHY) {
Scene *sce = scene; // to be able to delete, scenes are set...
@ -1381,16 +1381,12 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
WM_window_set_active_scene(bmain, C, win, sce);
}
str = "Select Object Hierarchy";
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_outliner_select_sync_from_object_tag(C);
selection_changed = true;
}
else if (event == OL_OP_DESELECT) {
outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_deselect_cb);
str = "Deselect Objects";
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_outliner_select_sync_from_object_tag(C);
selection_changed = true;
}
else if (event == OL_OP_DELETE) {
ViewLayer *view_layer = CTX_data_view_layer(C);
@ -1413,6 +1409,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active);
}
selection_changed = true;
}
else if (event == OL_OP_DELETE_HIERARCHY) {
ViewLayer *view_layer = CTX_data_view_layer(C);
@ -1449,6 +1446,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active);
}
selection_changed = true;
}
else if (event == OL_OP_REMAP) {
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_remap_cb, NULL);
@ -1477,6 +1475,12 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if (selection_changed) {
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_outliner_select_sync_from_object_tag(C);
}
ED_undo_push(C, str);
return OPERATOR_FINISHED;