Outliner: avoid creating unnecessary undo steps

The `OUTLINER_OT_item_activate` operator, although it detects when
something changes, always returns `OPERATOR_FINISHED` and thus induces
the creation of undo steps.

So return `OPERATOR_CANCELLED` when nothing changes.

Ref T94080

Reviewed By: Severin

Maniphest Tasks: T94080

Differential Revision: https://developer.blender.org/D13638
This commit is contained in:
Germano Cavalcante 2022-01-27 15:30:22 -03:00 committed by Germano Cavalcante
parent a21f1e81e0
commit 3775615aea
Notes: blender-bot 2023-02-14 11:01:33 +01:00
Referenced by issue #94080, Clicking on empty space in editors creates undo step
1 changed files with 12 additions and 11 deletions

View File

@ -1611,8 +1611,7 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
if (!(te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]))) {
if (deselect_all) {
outliner_flag_set(&space_outliner->tree, TSE_SELECTED, false);
changed = true;
changed |= outliner_flag_set(&space_outliner->tree, TSE_SELECTED, false);
}
}
/* Don't allow toggle on scene collection */
@ -1660,17 +1659,19 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
changed = true;
}
if (changed) {
if (rebuild_tree) {
ED_region_tag_redraw(region);
}
else {
ED_region_tag_redraw_no_rebuild(region);
}
ED_outliner_select_sync_from_outliner(C, space_outliner);
if (!changed) {
return OPERATOR_CANCELLED;
}
if (rebuild_tree) {
ED_region_tag_redraw(region);
}
else {
ED_region_tag_redraw_no_rebuild(region);
}
ED_outliner_select_sync_from_outliner(C, space_outliner);
return OPERATOR_FINISHED;
}