minor code cleanup
authorCampbell Barton <ideasman42@gmail.com>
Wed, 5 Sep 2012 00:51:31 +0000 (00:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 5 Sep 2012 00:51:31 +0000 (00:51 +0000)
animation_motion_trail.py
cmu_mocap_browser/__init__.py
curve_tools.py
mesh_show_vgroup_weights.py
render_time.py
space_view3d_enhanced_3d_cursor.py
space_view3d_game_props_visualiser.py
space_view3d_paint_bprojection.py

index 69829b6929099028000cf4bb93097209d1011188..ec6d5f89b53a95f5408e90936b2da3239bcd44f3 100644 (file)
@@ -1525,14 +1525,15 @@ class MotionTrailOperator(bpy.types.Operator):
                 
                 for kmi in kmis:
                     kmi.active = False
-                
-                context.window_manager.modal_handler_add(self)
+
                 self._handle1 = context.region.callback_add(calc_callback,
                     (self, context), 'POST_VIEW')
                 self._handle2 = context.region.callback_add(draw_callback,
                     (self, context), 'POST_PIXEL')
                 if context.area:
                     context.area.tag_redraw()
+
+                context.window_manager.modal_handler_add(self)
             else:
                 # disable
                 context.window_manager.motion_trail.enabled = -1
index b82b69ace99a1943ee4bf4febd3caad91d6d30bc..db7d738645851b64f9afc88c8fb16c9c75417516 100644 (file)
@@ -206,11 +206,11 @@ class CMUMocapDownloadImport(bpy.types.Operator):
                 ['b', 'Kb', 'Mb', 'Gb', 'Tb', 'Eb', 'Pb'][m])  # :-p
             self.fout = open(self.local_file, 'wb')
             self.recv = 0
-            context.window_manager.modal_handler_add(self)
             self.handle = context.region.\
                 callback_add(draw_callback, (self, context), 'POST_PIXEL')
             self.timer = context.window_manager.\
                 event_timer_add(0.001, context.window)
+            context.window_manager.modal_handler_add(self)
             return {'RUNNING_MODAL'}
         else:
             self.import_or_open()
index 74169fb13ddf20a9dc899767398081bb92161204..6189f0a85dc36e650c27940b17272d9e15a5e897 100644 (file)
@@ -1195,7 +1195,6 @@ class CutCurveOperator(bpy.types.Operator):
     def invoke(self, context, event):
 
         if context.object:
-
             context.window_manager.modal_handler_add(self)
             return {'RUNNING_MODAL'}
         else:
index 460ebe8884d76dd980f3631d12df788bc9e4c78f..f9fbcf762d29397c85df925ce030db9bf5f4c14e 100644 (file)
@@ -172,11 +172,11 @@ class ShowVGroupWeights(bpy.types.Operator):
             if context.scene.display_indices < 1:
                 # operator is called for the first time, start everything
                 context.scene.display_indices = 1
-                context.window_manager.modal_handler_add(self)
                 self.handle1 = context.region.callback_add(calc_callback,
                     (self, context), 'POST_VIEW')
                 self.handle2 = context.region.callback_add(draw_callback,
                     (self, context), 'POST_PIXEL')
+                context.window_manager.modal_handler_add(self)
                 return {'RUNNING_MODAL'}
             else:
                 # operator is called again, stop displaying
index f2bfe045d45ba9d127fb59ba192ba18a4c1d80f5..e7532a430000fc55dc2359545a6c3371132ec91a 100644 (file)
@@ -119,11 +119,11 @@ class RenderTimeHUD(bpy.types.Operator):
     def invoke(self, context, event):
         if context.area.type == 'IMAGE_EDITOR':
             if timer["hud"] == False:
-                context.window_manager.modal_handler_add(self)
-
                 # Add the region OpenGL drawing callback
                 self._handle = context.region.callback_add(draw_callback_px, (self, context), 'POST_PIXEL')
                 timer["hud"] = True
+
+                context.window_manager.modal_handler_add(self)
                 return {'RUNNING_MODAL'}
             else:
                 timer["hud"] = False
index 706cc8f2079540c5378feffe06ab74670eaf5d22..83ae0c1a0ab32d76de86d66eadac45fa84bbafe7 100644 (file)
@@ -308,7 +308,7 @@ class EnhancedSetCursor(bpy.types.Operator):
         
         # Initial run
         self.try_process_input(context, event, True)
-        
+
         context.window_manager.modal_handler_add(self)
         return {'RUNNING_MODAL'}
     
@@ -4643,10 +4643,7 @@ class CursorMonitor(bpy.types.Operator):
         CursorMonitor.is_running = True
         
         CursorDynamicSettings.recalc_csu(context, 'PRESS')
-        
-        # Currently there seems to be only one window manager
-        context.window_manager.modal_handler_add(self)
-        
+
         # I suppose that cursor position would change
         # only with user interaction.
         #self._timer = context.window_manager. \
@@ -4669,6 +4666,9 @@ class CursorMonitor(bpy.types.Operator):
         
         # Here we cannot return 'PASS_THROUGH',
         # or Blender will crash!
+
+        # Currently there seems to be only one window
+        context.window_manager.modal_handler_add(self)
         return {'RUNNING_MODAL'}
     
     def cancel(self, context):
@@ -5535,12 +5535,11 @@ class DelayRegistrationOperator(bpy.types.Operator):
     
     def execute(self, context):
         self.keymap_updated = False
-        
-        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):
index fd2bcb3e209a3d33f3da2e3140feb84001514e4a..ea7a1a5a8611a7e4d09451355ef06c9b6ca45dee 100644 (file)
@@ -161,11 +161,12 @@ class GamePropertyVisualizer(bpy.types.Operator):
                 print('init')
                 # operator is called for the first time, start everything
                 context.scene.display_game_properties = 1
-                context.window_manager.modal_handler_add(self)
                 self.handle1 = context.region.callback_add(calc_callback,
                     (self, context), 'POST_VIEW')
                 self.handle2 = context.region.callback_add(draw_callback,
                     (self, context), 'POST_PIXEL')
+
+                context.window_manager.modal_handler_add(self)
                 return {'RUNNING_MODAL'}
             else:
                 # operator is called again, stop displaying
index c579525a710ee42d61b49590531636e2f4b10848..5d0da2ab074a0a07b13da39647808410e2640dcf 100644 (file)
@@ -1151,13 +1151,13 @@ class RotateView3D(Operator):
         return{'FINISHED'}
 
     def invoke(self, context, event):
-        context.window_manager.modal_handler_add(self)
         self.first_mouse = Vector((event.mouse_region_x,event.mouse_region_y))
         self.first_time = True
         for sub in context.object.modifiers:
-            if sub.type in ['SUBSURF', 'MULTIRES']:
+            if sub.type in {'SUBSURF', 'MULTIRES'}:
                 self.tmp_level = sub.levels
                 sub.levels = 0
+        context.window_manager.modal_handler_add(self)
         return {'RUNNING_MODAL'}
 
 # Oprerator Class to pan the view3D
@@ -1206,14 +1206,13 @@ class PanView3D(bpy.types.Operator):
         return {'RUNNING_MODAL'}
                 
     def invoke(self, context, event):
-        context.window_manager.modal_handler_add(self)
         self.first_mouse.x = event.mouse_region_x
         self.first_mouse.y = event.mouse_region_y   
         for sub in context.object.modifiers:
-            if sub.type in ['SUBSURF', 'MULTIRES']:
+            if sub.type in {'SUBSURF', 'MULTIRES'}:
                 self.tmp_level = sub.levels
-                sub.levels = 0  
-                      
+                sub.levels = 0
+        context.window_manager.modal_handler_add(self)
         return {'RUNNING_MODAL'}
 
     def execute(self, context):