Nicer resetting of _loop_kicking_operator_running

This commit is contained in:
Sybren A. Stüvel 2016-06-17 16:27:45 +02:00
parent eb77461ca0
commit 56137c485f

View File

@ -94,7 +94,6 @@ def erase_async_loop():
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
loop.stop() loop.stop()
_loop_kicking_operator_running = False
class AsyncLoopModalOperator(bpy.types.Operator): class AsyncLoopModalOperator(bpy.types.Operator):
@ -104,6 +103,14 @@ class AsyncLoopModalOperator(bpy.types.Operator):
timer = None timer = None
log = logging.getLogger(__name__ + '.AsyncLoopModalOperator') log = logging.getLogger(__name__ + '.AsyncLoopModalOperator')
def __del__(self):
global _loop_kicking_operator_running
# This can be required when the operator is running while Blender
# (re)loads a file. The operator then doesn't get the chance to
# finish the async tasks, hence stop_after_this_kick is never True.
_loop_kicking_operator_running = False
def execute(self, context): def execute(self, context):
return self.invoke(context, None) return self.invoke(context, None)