UI: restore confirmation popups for delete operators.

It turned out this was leading to accidental deleting in some cases when the
info message was missed by users. Fixes T37801.
This commit is contained in:
Brecht Van Lommel 2013-12-20 01:38:07 +01:00
parent 29e3b09825
commit b2fdc591c3
Notes: blender-bot 2023-02-14 11:29:49 +01:00
Referenced by issue #39189, Node editor Map Uv requires an scale node to work
Referenced by issue #37978, Switching material output nodes is unpredictable
Referenced by issue #37914, New vertex group behaves as if assigned until modified
Referenced by issue #37920, Repeatedly calling LibLoad and LibFree on the same library / blend will cause a crash.
Referenced by issue #37801, x no longer prompts for confirmation
8 changed files with 45 additions and 52 deletions

View File

@ -1514,9 +1514,9 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot)
* it is more useful for animators working in the 3D view.
*/
static int clear_anim_v3d_exec(bContext *C, wmOperator *op)
static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
{
int num_deleted = 0;
bool changed = false;
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
@ -1557,18 +1557,17 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *op)
/* delete F-Curve completely */
if (can_delete) {
ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
num_deleted++;
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
changed = true;
}
}
}
/* update... */
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
CTX_DATA_END;
if (num_deleted > 0)
BKE_reportf(op->reports, RPT_INFO, "Deleted %d animation F-Curves from selected objects", num_deleted);
if (!changed) {
return OPERATOR_CANCELLED;
}
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
@ -1584,6 +1583,7 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
ot->idname = "ANIM_OT_keyframe_clear_v3d";
/* callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = clear_anim_v3d_exec;
ot->poll = ED_operator_areaactive;
@ -1647,6 +1647,7 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
ot->idname = "ANIM_OT_keyframe_delete_v3d";
/* callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_key_v3d_exec;
ot->poll = ED_operator_areaactive;

View File

@ -1137,13 +1137,13 @@ void ARMATURE_OT_split(wmOperatorType *ot)
/* previously delete_armature */
/* only editmode! */
static int armature_delete_selected_exec(bContext *C, wmOperator *op)
static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
{
bArmature *arm;
EditBone *curBone, *ebone_next;
bConstraint *con;
Object *obedit = CTX_data_edit_object(C); // XXX get from context
int num_deleted = 0;
bool changed = false;
arm = obedit->data;
/* cancel if nothing selected */
@ -1200,12 +1200,13 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *op)
if (curBone->flag & BONE_SELECTED) {
if (curBone == arm->act_edbone) arm->act_edbone = NULL;
ED_armature_edit_bone_remove(arm, curBone);
num_deleted++;
changed = true;
}
}
}
BKE_reportf(op->reports, RPT_INFO, "Deleted %d bones", num_deleted);
if (!changed)
return OPERATOR_CANCELLED;
ED_armature_sync_selection(arm->edbo);
@ -1222,6 +1223,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
ot->description = "Remove selected bones from the armature";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = armature_delete_selected_exec;
ot->poll = ED_operator_editarmature;

View File

@ -38,7 +38,6 @@
#include "BKE_depsgraph.h"
#include "BKE_main.h"
#include "BKE_mask.h"
#include "BKE_report.h"
#include "DNA_scene_types.h"
#include "DNA_mask_types.h"
@ -943,12 +942,12 @@ static void delete_feather_points(MaskSplinePoint *point)
}
}
static int delete_exec(bContext *C, wmOperator *op)
static int delete_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
int num_deleted = 0;
bool changed = false;
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
MaskSpline *spline;
@ -984,8 +983,6 @@ static int delete_exec(bContext *C, wmOperator *op)
}
BKE_mask_layer_shape_changed_remove(masklay, mask_layer_shape_ofs, tot_point_orig);
num_deleted++;
}
else {
MaskSplinePoint *new_points;
@ -1013,8 +1010,6 @@ static int delete_exec(bContext *C, wmOperator *op)
spline->tot_point--;
BKE_mask_layer_shape_changed_remove(masklay, mask_layer_shape_ofs + j, 1);
num_deleted++;
}
}
@ -1026,6 +1021,7 @@ static int delete_exec(bContext *C, wmOperator *op)
ED_mask_select_flush_all(mask);
}
changed = true;
spline = next_spline;
}
@ -1036,16 +1032,15 @@ static int delete_exec(bContext *C, wmOperator *op)
}
}
if (num_deleted == 0)
if (!changed) {
return OPERATOR_CANCELLED;
}
/* TODO: only update edited splines */
BKE_mask_update_display(mask, CFRA);
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
BKE_reportf(op->reports, RPT_INFO, "Deleted %d control points from mask '%s'", num_deleted, mask->id.name);
return OPERATOR_FINISHED;
}
@ -1057,6 +1052,7 @@ void MASK_OT_delete(wmOperatorType *ot)
ot->idname = "MASK_OT_delete";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_exec;
ot->poll = ED_maskedit_mask_poll;

View File

@ -1057,7 +1057,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
const short use_global = RNA_boolean_get(op->ptr, "use_global");
int num_deleted = 0;
bool changed = false;
if (CTX_data_edit_object(C))
return OPERATOR_CANCELLED;
@ -1069,7 +1069,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
/* remove from current scene only */
ED_base_object_free_and_unlink(bmain, scene, base);
num_deleted++;
changed = true;
if (use_global) {
Scene *scene_iter;
@ -1089,6 +1089,9 @@ static int object_delete_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
if (!changed)
return OPERATOR_CANCELLED;
/* delete has to handle all open scenes */
flag_listbase_ids(&bmain->scene, LIB_DOIT, 1);
for (win = wm->windows.first; win; win = win->next) {
@ -1104,9 +1107,6 @@ static int object_delete_exec(bContext *C, wmOperator *op)
}
}
if (num_deleted > 0)
BKE_reportf(op->reports, RPT_INFO, "Deleted %d objects", num_deleted);
return OPERATOR_FINISHED;
}
@ -1118,6 +1118,7 @@ void OBJECT_OT_delete(wmOperatorType *ot)
ot->idname = "OBJECT_OT_delete";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = object_delete_exec;
ot->poll = ED_operator_objectmode;

View File

@ -823,17 +823,17 @@ static bool delete_action_keys(bAnimContext *ac)
/* ------------------- */
static int actkeys_delete_exec(bContext *C, wmOperator *op)
static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
bool changed;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* delete keyframes */
changed = delete_action_keys(&ac);
if (!delete_action_keys(&ac))
return OPERATOR_CANCELLED;
/* validate keyframes after editing */
if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
@ -842,9 +842,6 @@ static int actkeys_delete_exec(bContext *C, wmOperator *op)
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
if (changed)
BKE_report(op->reports, RPT_INFO, "Deleted selected keyframes");
return OPERATOR_FINISHED;
}
@ -856,6 +853,7 @@ void ACTION_OT_delete(wmOperatorType *ot)
ot->description = "Remove all selected keyframes";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = actkeys_delete_exec;
ot->poll = ED_operator_action_active;

View File

@ -43,7 +43,6 @@
#include "BKE_movieclip.h"
#include "BKE_tracking.h"
#include "BKE_depsgraph.h"
#include "BKE_report.h"
#include "WM_api.h"
#include "WM_types.h"
@ -472,18 +471,17 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot)
/******************** delete curve operator ********************/
static int delete_curve_exec(bContext *C, wmOperator *op)
static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
if (act_track) {
clip_delete_track(C, clip, act_track);
if (!act_track)
return OPERATOR_CANCELLED;
BKE_report(op->reports, RPT_INFO, "Deleted track");
}
clip_delete_track(C, clip, act_track);
return OPERATOR_FINISHED;
}
@ -496,6 +494,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot)
ot->idname = "CLIP_OT_graph_delete_curve";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_curve_exec;
ot->poll = ED_space_clip_tracking_poll;

View File

@ -234,7 +234,7 @@ void CLIP_OT_add_marker_at_click(wmOperatorType *ot)
/********************** delete track operator *********************/
static int delete_track_exec(bContext *C, wmOperator *op)
static int delete_track_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
@ -274,10 +274,8 @@ static int delete_track_exec(bContext *C, wmOperator *op)
/* nothing selected now, unlock view so it can be scrolled nice again */
sc->flag &= ~SC_LOCK_SELECTION;
if (changed) {
BKE_report(op->reports, RPT_INFO, "Deleted selected tracks");
if (changed)
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
}
return OPERATOR_FINISHED;
}
@ -290,6 +288,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot)
ot->description = "Delete selected tracks";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_track_exec;
ot->poll = ED_space_clip_tracking_poll;
@ -299,7 +298,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot)
/********************** delete marker operator *********************/
static int delete_marker_exec(bContext *C, wmOperator *op)
static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
@ -359,8 +358,6 @@ static int delete_marker_exec(bContext *C, wmOperator *op)
if (!changed)
return OPERATOR_CANCELLED;
BKE_report(op->reports, RPT_INFO, "Deleted markers for current frame from selected tracks");
return OPERATOR_FINISHED;
}
@ -372,6 +369,7 @@ void CLIP_OT_delete_marker(wmOperatorType *ot)
ot->description = "Delete marker for current frame from selected tracks";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_marker_exec;
ot->poll = ED_space_clip_tracking_poll;

View File

@ -908,17 +908,17 @@ static bool delete_graph_keys(bAnimContext *ac)
/* ------------------- */
static int graphkeys_delete_exec(bContext *C, wmOperator *op)
static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
bool changed;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* delete keyframes */
changed = delete_graph_keys(&ac);
if (!delete_graph_keys(&ac))
return OPERATOR_CANCELLED;
/* validate keyframes after editing */
ANIM_editkeyframes_refresh(&ac);
@ -926,9 +926,6 @@ static int graphkeys_delete_exec(bContext *C, wmOperator *op)
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
if (changed)
BKE_report(op->reports, RPT_INFO, "Deleted selected keyframes");
return OPERATOR_FINISHED;
}
@ -940,6 +937,7 @@ void GRAPH_OT_delete(wmOperatorType *ot)
ot->description = "Remove all selected keyframes";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = graphkeys_delete_exec;
ot->poll = graphop_editable_keyframes_poll;