Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-06-06 15:04:54 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-06-06 15:04:54 +0400
commita43309e8d4fc09d31acb4030b13f1c22c9ddf22a (patch)
treeebc83c257a1a9366f48273178971aa00cdfc1c99
parent4d0026f7b9995a9d51fc485f83b8d68a30362fbc (diff)
Added cancel callbacks to modal operators which allocates memory
in invoke callback. This prevents unfreed memory blocks when quiting Bledner with modal operator running.
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c1
-rw-r--r--source/blender/editors/animation/anim_markers.c7
-rw-r--r--source/blender/editors/animation/anim_ops.c1
-rw-r--r--source/blender/editors/interface/view2d_ops.c20
-rw-r--r--source/blender/editors/mesh/editmesh_loop.c1
-rw-r--r--source/blender/editors/screen/screen_ops.c20
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h1
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c13
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c16
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c19
-rw-r--r--source/blender/editors/space_action/action_select.c1
-rw-r--r--source/blender/editors/space_file/file_ops.c1
-rw-r--r--source/blender/editors/space_graph/graph_select.c1
-rw-r--r--source/blender/editors/space_image/image_ops.c1
-rw-r--r--source/blender/editors/space_info/info_report.c1
-rw-r--r--source/blender/editors/space_logic/logic_buttons.c1
-rw-r--r--source/blender/editors/space_nla/nla_select.c1
-rw-r--r--source/blender/editors/space_node/node_edit.c31
-rw-r--r--source/blender/editors/space_node/node_select.c1
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c1
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c34
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c3
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c2
-rw-r--r--source/blender/windowmanager/WM_api.h5
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c77
26 files changed, 242 insertions, 19 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index f755df79986..9145cc2b79d 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1881,6 +1881,7 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= animchannels_borderselect_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= animedit_poll_channels_nla_tweakmode_off;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index c802ba621f1..c6e55427034 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -717,7 +717,7 @@ static void ed_marker_move_apply(wmOperator *op)
}
/* only for modal */
-static void ed_marker_move_cancel(bContext *C, wmOperator *op)
+static int ed_marker_move_cancel(bContext *C, wmOperator *op)
{
RNA_int_set(op->ptr, "frames", 0);
ed_marker_move_apply(op);
@@ -725,6 +725,8 @@ static void ed_marker_move_cancel(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL);
+
+ return OPERATOR_CANCELLED;
}
@@ -886,6 +888,7 @@ static void MARKER_OT_move(wmOperatorType *ot)
ot->invoke= ed_marker_move_invoke_wrapper;
ot->modal= ed_marker_move_modal;
ot->poll= ed_markers_poll_selected_markers;
+ ot->cancel= ed_marker_move_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -980,6 +983,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot)
ot->invoke= ed_marker_duplicate_invoke_wrapper;
ot->modal= ed_marker_move_modal;
ot->poll= ed_markers_poll_selected_markers;
+ ot->cancel= ed_marker_move_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1185,6 +1189,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot)
ot->exec= ed_marker_border_select_exec;
ot->invoke= ed_marker_select_border_invoke_wrapper;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ed_markers_poll_markers_exist;
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 93d99c59a0e..0e0bf275d8f 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -224,6 +224,7 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= previewrange_define_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_animview_active;
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index f7bff168a33..434334258af 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -876,6 +876,13 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
}
}
+static int view_zoomdrag_cancel(bContext *C, wmOperator *op)
+{
+ view_zoomdrag_exit(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
/* for 'redo' only, with no user input */
static int view_zoomdrag_exec(bContext *C, wmOperator *op)
{
@@ -1065,6 +1072,7 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot)
ot->exec= view_zoomdrag_exec;
ot->invoke= view_zoomdrag_invoke;
ot->modal= view_zoomdrag_modal;
+ ot->cancel= view_zoomdrag_cancel;
ot->poll= view_zoom_poll;
@@ -1165,6 +1173,7 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= view_borderzoom_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= view_zoom_poll;
@@ -1352,7 +1361,14 @@ static void scroller_activate_exit(bContext *C, wmOperator *op)
ED_region_tag_redraw(CTX_wm_region(C));
}
-}
+}
+
+static int scroller_activate_cancel(bContext *C, wmOperator *op)
+{
+ scroller_activate_exit(C, op);
+
+ return OPERATOR_CANCELLED;
+}
/* apply transform to view (i.e. adjust 'cur' rect) */
static void scroller_activate_apply(bContext *C, wmOperator *op)
@@ -1561,6 +1577,8 @@ static void VIEW2D_OT_scroller_activate(wmOperatorType *ot)
/* api callbacks */
ot->invoke= scroller_activate_invoke;
ot->modal= scroller_activate_modal;
+ ot->cancel= scroller_activate_cancel;
+
ot->poll= view2d_poll;
}
diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c
index d7e59e0a68f..32971ca77ed 100644
--- a/source/blender/editors/mesh/editmesh_loop.c
+++ b/source/blender/editors/mesh/editmesh_loop.c
@@ -716,6 +716,7 @@ void MESH_OT_knife_cut(wmOperatorType *ot)
ot->invoke= WM_gesture_lines_invoke;
ot->modal= WM_gesture_lines_modal;
ot->exec= knife_cut_exec;
+ ot->cancel= WM_gesture_lines_cancel;
ot->poll= EM_view3d_poll;
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 9e840e75578..4e67069185e 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -627,6 +627,13 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+static int actionzone_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ actionzone_exit(op);
+
+ return OPERATOR_CANCELLED;
+}
+
static void SCREEN_OT_actionzone(wmOperatorType *ot)
{
/* identifiers */
@@ -637,6 +644,7 @@ static void SCREEN_OT_actionzone(wmOperatorType *ot)
ot->invoke= actionzone_invoke;
ot->modal= actionzone_modal;
ot->poll= actionzone_area_poll;
+ ot->cancel= actionzone_cancel;
ot->flag= OPTYPE_BLOCKING;
@@ -759,6 +767,7 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
ot->invoke= area_swap_invoke;
ot->modal= area_swap_modal;
ot->poll= ED_operator_areaactive;
+ ot->cancel= area_swap_cancel;
ot->flag= OPTYPE_BLOCKING;
}
@@ -1494,6 +1503,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot)
ot->exec= area_split_exec;
ot->invoke= area_split_invoke;
ot->modal= area_split_modal;
+ ot->cancel= area_split_cancel;
ot->poll= screen_active_editable;
ot->flag= OPTYPE_BLOCKING;
@@ -1693,6 +1703,13 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ MEM_freeN(op->customdata);
+ op->customdata = NULL;
+
+ return OPERATOR_CANCELLED;
+}
static void SCREEN_OT_region_scale(wmOperatorType *ot)
{
@@ -1703,6 +1720,7 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot)
ot->invoke= region_scale_invoke;
ot->modal= region_scale_modal;
+ ot->cancel= region_scale_cancel;
ot->poll= ED_operator_areaactive;
@@ -2257,6 +2275,7 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
ot->invoke= area_join_invoke;
ot->modal= area_join_modal;
ot->poll= screen_active_editable;
+ ot->cancel= area_join_cancel;
ot->flag= OPTYPE_BLOCKING;
@@ -3053,6 +3072,7 @@ static void SCREEN_OT_border_select(wmOperatorType *ot)
ot->exec= border_select_do;
ot->invoke= WM_border_select_invoke;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_areaactive;
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index bb877e4b1ee..5a0ee19d6c9 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -65,6 +65,7 @@ int paint_space_stroke_enabled(struct Brush *br);
int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int paint_stroke_exec(struct bContext *C, struct wmOperator *op);
+int paint_stroke_cancel(struct bContext *C, struct wmOperator *op);
struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
void *paint_stroke_mode_data(struct PaintStroke *stroke);
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 58c3446673c..7ddf5dff000 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -916,6 +916,19 @@ int paint_stroke_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+int paint_stroke_cancel(bContext *C, wmOperator *op)
+{
+ PaintStroke *stroke = op->customdata;
+
+ if(stroke->done)
+ stroke->done(C, stroke);
+
+ MEM_freeN(stroke);
+ op->customdata = NULL;
+
+ return OPERATOR_CANCELLED;
+}
+
ViewContext *paint_stroke_view_context(PaintStroke *stroke)
{
return &stroke->vc;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index c35b742eb9e..3da19ba7346 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1600,6 +1600,13 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+static int wpaint_cancel(bContext *C, wmOperator *op)
+{
+ paint_stroke_cancel(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
void PAINT_OT_weight_paint(wmOperatorType *ot)
{
@@ -1612,6 +1619,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
ot->modal= paint_stroke_modal;
/* ot->exec= vpaint_exec; <-- needs stroke property */
ot->poll= weight_paint_poll;
+ ot->cancel= wpaint_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@ -1892,6 +1900,13 @@ static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+static int vpaint_cancel(bContext *C, wmOperator *op)
+{
+ paint_stroke_cancel(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
void PAINT_OT_vertex_paint(wmOperatorType *ot)
{
/* identifiers */
@@ -1903,6 +1918,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
ot->modal= paint_stroke_modal;
/* ot->exec= vpaint_exec; <-- needs stroke property */
ot->poll= vertex_paint_poll;
+ ot->cancel= vpaint_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 20e74702067..cab8c522a89 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3559,6 +3559,24 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int sculpt_brush_stroke_cacel(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+
+ paint_stroke_cancel(C, op);
+
+ if(ss->cache) {
+ sculpt_cache_free(ss->cache);
+ ss->cache = NULL;
+ }
+
+ sculpt_brush_exit_tex(sd);
+
+ return OPERATOR_CANCELLED;
+}
+
static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
{
static EnumPropertyItem stroke_mode_items[] = {
@@ -3577,6 +3595,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
ot->modal= paint_stroke_modal;
ot->exec= sculpt_brush_stroke_exec;
ot->poll= sculpt_poll;
+ ot->cancel= sculpt_brush_stroke_cacel;
/* flags (sculpt does own undo? (ton) */
ot->flag= OPTYPE_BLOCKING;
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index be8547afa23..4d0043913ab 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -332,6 +332,7 @@ void ACTION_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= actkeys_borderselect_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_action_active;
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 9662b4b401f..a5d516a1417 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -301,6 +301,7 @@ void FILE_OT_select_border(wmOperatorType *ot)
ot->exec= file_border_select_exec;
ot->modal= file_border_select_modal;
ot->poll= ED_operator_file_active;
+ ot->cancel= WM_border_select_cancel;
/* rna */
WM_operator_properties_gesture_border(ot, 0);
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 76883027df1..cb799b85d3a 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -344,6 +344,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= graphkeys_borderselect_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= graphop_visible_keyframes_poll;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index f48daa39c59..10b8cb238aa 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1925,6 +1925,7 @@ void IMAGE_OT_sample_line(wmOperatorType *ot)
ot->modal= WM_gesture_straightline_modal;
ot->exec= sample_line_exec;
ot->poll= space_image_main_area_poll;
+ ot->cancel= WM_gesture_straightline_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 937b683e880..c8bda434227 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -302,6 +302,7 @@ void INFO_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= borderselect_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_info_active;
diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c
index e894fd9cff5..16e916928a9 100644
--- a/source/blender/editors/space_logic/logic_buttons.c
+++ b/source/blender/editors/space_logic/logic_buttons.c
@@ -206,6 +206,7 @@ void LOGIC_OT_links_cut(wmOperatorType *ot)
ot->invoke= WM_gesture_lines_invoke;
ot->modal= WM_gesture_lines_modal;
ot->exec= cut_links_exec;
+ ot->cancel= WM_gesture_lines_cancel;
ot->poll= ED_operator_logic_active;
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 0f0a4c0ad4c..8ef63b9a83d 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -333,6 +333,7 @@ void NLA_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= nlaedit_borderselect_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= nlaop_poll_tweakmode_off;
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index d967e2240e6..99f2ea99efc 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -1086,6 +1086,13 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+static int snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ MEM_freeN(op->customdata);
+ op->customdata= NULL;
+
+ return OPERATOR_CANCELLED;
+}
void NODE_OT_backimage_move(wmOperatorType *ot)
{
@@ -1098,6 +1105,7 @@ void NODE_OT_backimage_move(wmOperatorType *ot)
ot->invoke= snode_bg_viewmove_invoke;
ot->modal= snode_bg_viewmove_modal;
ot->poll= composite_node_active;
+ ot->cancel= snode_bg_viewmove_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING;
@@ -1384,6 +1392,14 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH;
}
+static int node_resize_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ MEM_freeN(op->customdata);
+ op->customdata= NULL;
+
+ return OPERATOR_CANCELLED;
+}
+
void NODE_OT_resize(wmOperatorType *ot)
{
/* identifiers */
@@ -1394,6 +1410,7 @@ void NODE_OT_resize(wmOperatorType *ot)
ot->invoke= node_resize_invoke;
ot->modal= node_resize_modal;
ot->poll= ED_operator_node_active;
+ ot->cancel= node_resize_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING;
@@ -2279,6 +2296,18 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
+static int node_link_cancel(bContext *C, wmOperator *op)
+{
+ SpaceNode *snode= CTX_wm_space_node(C);
+ bNodeLinkDrag *nldrag= op->customdata;
+
+ nodeRemLink(snode->edittree, nldrag->link);
+ BLI_remlink(&snode->linkdrag, nldrag);
+ MEM_freeN(nldrag);
+
+ return OPERATOR_CANCELLED;
+}
+
void NODE_OT_link(wmOperatorType *ot)
{
/* identifiers */
@@ -2290,6 +2319,7 @@ void NODE_OT_link(wmOperatorType *ot)
ot->modal= node_link_modal;
// ot->exec= node_link_exec;
ot->poll= ED_operator_node_active;
+ ot->cancel= node_link_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@ -2402,6 +2432,7 @@ void NODE_OT_links_cut(wmOperatorType *ot)
ot->invoke= WM_gesture_lines_invoke;
ot->modal= WM_gesture_lines_modal;
ot->exec= cut_links_exec;
+ ot->cancel= WM_gesture_lines_cancel;
ot->poll= ED_operator_node_active;
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index a1ef75f3976..1abcaccc939 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -215,6 +215,7 @@ void NODE_OT_select_border(wmOperatorType *ot)
ot->invoke= node_border_select_invoke;
ot->exec= node_borderselect_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_node_active;
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 71ed7928bc8..6900271deea 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -2817,6 +2817,7 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
ot->exec= view_ghost_border_exec;
ot->modal= WM_border_select_modal;
ot->poll= sequencer_view_poll;
+ ot->cancel= WM_border_select_cancel;
/* flags */
ot->flag= 0;
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 8b4bfb2e042..8d5f372f55e 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -871,6 +871,7 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= sequencer_borderselect_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_sequencer_active;
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 31aae28dd61..9ff73767b4c 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -904,6 +904,13 @@ static int view3d_camera_active_poll(bContext *C)
return 0;
}
+static int viewrotate_cancel(bContext *C, wmOperator *op)
+{
+ viewops_data_free(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
void VIEW3D_OT_rotate(wmOperatorType *ot)
{
@@ -916,6 +923,7 @@ void VIEW3D_OT_rotate(wmOperatorType *ot)
ot->invoke= viewrotate_invoke;
ot->modal= viewrotate_modal;
ot->poll= ED_operator_region_view3d_active;
+ ot->cancel= viewrotate_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -1058,6 +1066,13 @@ static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
+static int viewmove_cancel(bContext *C, wmOperator *op)
+{
+ viewops_data_free(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
void VIEW3D_OT_move(wmOperatorType *ot)
{
@@ -1070,6 +1085,7 @@ void VIEW3D_OT_move(wmOperatorType *ot)
ot->invoke= viewmove_invoke;
ot->modal= viewmove_modal;
ot->poll= ED_operator_view3d_active;
+ ot->cancel= viewmove_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -1414,6 +1430,12 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_FINISHED;
}
+static int viewzoom_cancel(bContext *C, wmOperator *op)
+{
+ viewops_data_free(C, op);
+
+ return OPERATOR_CANCELLED;
+}
void VIEW3D_OT_zoom(wmOperatorType *ot)
{
@@ -1427,6 +1449,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
ot->exec= viewzoom_exec;
ot->modal= viewzoom_modal;
ot->poll= ED_operator_region_view3d_active;
+ ot->cancel= viewzoom_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -1641,6 +1664,13 @@ static int viewdolly_poll(bContext *C)
return 0;
}
+static int viewdolly_cancel(bContext *C, wmOperator *op)
+{
+ viewops_data_free(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
void VIEW3D_OT_dolly(wmOperatorType *ot)
{
/* identifiers */
@@ -1653,6 +1683,7 @@ void VIEW3D_OT_dolly(wmOperatorType *ot)
ot->exec= viewdolly_exec;
ot->modal= viewdolly_modal;
ot->poll= viewdolly_poll;
+ ot->cancel= viewdolly_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -2046,6 +2077,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= render_border_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= view3d_camera_active_poll;
@@ -2201,6 +2233,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot)
ot->invoke= view3d_zoom_border_invoke;
ot->exec= view3d_zoom_border_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_region_view3d_active;
@@ -2839,6 +2872,7 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot)
ot->invoke= view3d_clipping_invoke;
ot->exec= view3d_clipping_exec;
ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_region_view3d_active;
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index fb3c0a63b7d..6391db7ae5e 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -875,6 +875,7 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot)
ot->modal= WM_gesture_lasso_modal;
ot->exec= view3d_lasso_select_exec;
ot->poll= view3d_selectable_data;
+ ot->cancel= WM_gesture_lasso_cancel;
/* flags */
ot->flag= OPTYPE_UNDO;
@@ -1829,6 +1830,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot)
ot->exec= view3d_borderselect_exec;
ot->modal= WM_border_select_modal;
ot->poll= view3d_selectable_data;
+ ot->cancel= WM_border_select_cancel;
/* flags */
ot->flag= OPTYPE_UNDO;
@@ -2308,6 +2310,7 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot)
ot->modal= WM_gesture_circle_modal;
ot->exec= view3d_circle_select_exec;
ot->poll= view3d_selectable_data;
+ ot->cancel= WM_gesture_circle_cancel;
/* flags */
ot->flag= OPTYPE_UNDO;
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 66b1e7d412b..c09f8cff02d 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2221,6 +2221,7 @@ static void UV_OT_select_border(wmOperatorType *ot)
ot->exec= border_select_exec;
ot->modal= WM_border_select_modal;
ot->poll= ED_operator_image_active; /* requires space image */;
+ ot->cancel= WM_border_select_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2310,6 +2311,7 @@ static void UV_OT_circle_select(wmOperatorType *ot)
ot->modal= WM_gesture_circle_modal;
ot->exec= circle_select_exec;
ot->poll= ED_operator_image_active; /* requires space image */;
+ ot->cancel= WM_gesture_circle_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 3f9a3f636d0..67294a8eb53 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -278,14 +278,19 @@ void WM_menutype_free(void);
/* default operator callbacks for border/circle/lasso */
int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_border_select_modal (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
+int WM_border_select_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
+int WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
+int WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
+int WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
+int WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op);
/* default operator for arearegions, generates event */
void WM_OT_tweak_gesture(struct wmOperatorType *ot);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 6959231a2fa..07739982763 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2244,6 +2244,13 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+int WM_border_select_cancel(bContext *C, wmOperator *op)
+{
+ wm_gesture_end(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
/* **************** circle gesture *************** */
/* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */
@@ -2340,6 +2347,13 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+int WM_gesture_circle_cancel(bContext *C, wmOperator *op)
+{
+ wm_gesture_end(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
#if 0
/* template to copy from */
void WM_OT_circle_gesture(wmOperatorType *ot)
@@ -2556,6 +2570,20 @@ int WM_gesture_lines_modal(bContext *C, wmOperator *op, wmEvent *event)
return WM_gesture_lasso_modal(C, op, event);
}
+int WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
+{
+ wm_gesture_end(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
+int WM_gesture_lines_cancel(bContext *C, wmOperator *op)
+{
+ wm_gesture_end(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
#if 0
/* template to copy from */
@@ -2677,6 +2705,13 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+int WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
+{
+ wm_gesture_end(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
#if 0
/* template to copy from */
void WM_OT_straightline_gesture(wmOperatorType *ot)
@@ -3060,6 +3095,28 @@ static void radial_control_set_value(RadialControl *rc, float val)
}
}
+static int radial_control_cancel(bContext *C, wmOperator *op)
+{
+ RadialControl *rc = op->customdata;
+ wmWindowManager *wm = CTX_wm_manager(C);
+
+ WM_paint_cursor_end(wm, rc->cursor);
+
+ /* restore original paint cursors */
+ wm->paintcursors = rc->orig_paintcursors;
+
+ /* not sure if this is a good notifier to use;
+ intended purpose is to update the UI so that the
+ new value is displayed in sliders/numfields */
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+ glDeleteTextures(1, &rc->gltex);
+
+ MEM_freeN(rc);
+
+ return OPERATOR_CANCELLED;
+}
+
static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
{
RadialControl *rc = op->customdata;
@@ -3125,23 +3182,8 @@ static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
ED_region_tag_redraw(CTX_wm_region(C));
- if(ret != OPERATOR_RUNNING_MODAL) {
- wm = CTX_wm_manager(C);
-
- WM_paint_cursor_end(wm, rc->cursor);
-
- /* restore original paint cursors */
- wm->paintcursors = rc->orig_paintcursors;
-
- /* not sure if this is a good notifier to use;
- intended purpose is to update the UI so that the
- new value is displayed in sliders/numfields */
- WM_event_add_notifier(C, NC_WINDOW, NULL);
-
- glDeleteTextures(1, &rc->gltex);
-
- MEM_freeN(rc);
- }
+ if(ret != OPERATOR_RUNNING_MODAL)
+ radial_control_cancel(C, op);
return ret;
}
@@ -3153,6 +3195,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
ot->invoke= radial_control_invoke;
ot->modal= radial_control_modal;
+ ot->cancel= radial_control_cancel;
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;