change templates to call modal_handler_add() is called last since any errors between calling this function and returning will crash blender. see [#30687]

This commit is contained in:
2012-09-05 00:11:39 +00:00
parent ebe29c3f84
commit 8cf9e5f8c3
6 changed files with 9 additions and 9 deletions

View File

@@ -735,7 +735,7 @@ class WM_OT_context_modal_mouse(Operator):
if not self._values:
self.report({'WARNING'}, "Nothing to operate on: %s[ ].%s" %
(self.data_path_iter, self.data_path_item))
(self.data_path_iter, self.data_path_item))
return {'CANCELLED'}
else:

View File

@@ -26,9 +26,10 @@ class ModalOperator(bpy.types.Operator):
def invoke(self, context, event):
if context.object:
context.window_manager.modal_handler_add(self)
self.first_mouse_x = event.mouse_x
self.first_value = context.object.location.x
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
else:
self.report({'WARNING'}, "No active object, could not finish")

View File

@@ -53,14 +53,13 @@ class ModalDrawOperator(bpy.types.Operator):
def invoke(self, context, event):
if context.area.type == 'VIEW_3D':
context.window_manager.modal_handler_add(self)
# Add the region OpenGL drawing callback
# draw in view space with 'POST_VIEW' and 'PRE_VIEW'
self._handle = context.region.callback_add(draw_callback_px, (self, context), 'POST_PIXEL')
self.mouse_path = []
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
else:
self.report({'WARNING'}, "View3D not found, cannot run operator")

View File

@@ -21,8 +21,8 @@ class ModalTimerOperator(bpy.types.Operator):
return {'PASS_THROUGH'}
def execute(self, context):
context.window_manager.modal_handler_add(self)
self._timer = context.window_manager.event_timer_add(0.1, context.window)
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
def cancel(self, context):

View File

@@ -45,14 +45,13 @@ class ViewOperator(bpy.types.Operator):
v3d = context.space_data
rv3d = v3d.region_3d
context.window_manager.modal_handler_add(self)
if rv3d.view_perspective == 'CAMERA':
rv3d.view_perspective = 'PERSP'
self._initial_mouse = Vector((event.mouse_x, event.mouse_y, 0.0))
self._initial_location = rv3d.view_location.copy()
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
else:
self.report({'WARNING'}, "Active space must be a View3d")

View File

@@ -1444,14 +1444,15 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
}
else {
printf("%s: error - missing modal\n", __func__);
printf("%s: error '%s' missing modal\n", __func__, op->idname);
}
}
else {
wmOperatorType *ot = WM_operatortype_find(event->keymap_idname, 0);
if (ot)
if (ot) {
retval = wm_operator_invoke(C, ot, event, properties, NULL, FALSE);
}
}
/* Finished and pass through flag as handled */