I have implemented a ModalTimerOperator, based on the sample in Blender's Python templates. At the moment it can be started, stopped and restarted by buttons (located in a menu added to the Info header for testing purposes). Later it should be started automatically when activating the addon I am working on. Important: The timer is intended to run until Blender is closed.
But now I observed that the timer's cancel() function is called as soon as a *.blend file is loaded, and it stops working therefore (I fear there may be other events doing the same). Putting a return statement into the cancel() function before calling wm.event_timer_remove() does not help.
So my questions are:
- How can I prevent my timer from being cancelled?
- Is it possible to restart the timer automatically if cancelled? (My try to restart it from a kind of Python watchdog thread causes Blender to crash as the API documentation's "Gotchas" chapter predicts.)
Background: I need the scene_update_post event because I change the view_matrix according to data from my 3D controller hardware.
– frisee Dec 18 '14 at 11:12class SimpleOperator(bpy.types.Operator): """Tooltip""" bl_idname = "object.simple_operator" bl_label = "Simple Object Operator"
bpy.utils.register_class(SimpleOperator) bpy.ops.object.simple_operator()
def sceneUpdateHandler(scene): bpy.ops.object.simple_operator()
#bpy.app.handlers.scene_update_post.append(sceneUpdateHandler) # <- Blender crashes bpy.app.handlers.load_pre.append(sceneUpdateHandler) # <- works fine`
– frisee Dec 18 '14 at 11:13