Skip to content

Commit

Permalink
Merge pull request #8 from sean1832/dev
Browse files Browse the repository at this point in the history
fix(template): value error on unregistration
  • Loading branch information
sean1832 authored Sep 16, 2024
2 parents 81ff470 + 31ea412 commit ee5ca10
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions templates/custom_data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ class TEXTBLOCK_OT_toggle_monitoring(bpy.types.Operator):

def execute(self, context):
if context.scene.is_monitoring:
# Stop monitoring
bpy.app.timers.unregister(monitor_text_block)
# Check if monitor_text_block is registered before unregistering
if bpy.app.timers.is_registered(monitor_text_block):
bpy.app.timers.unregister(monitor_text_block)
self.report({"INFO"}, "Stopped text block monitoring")
else:
self.report({"WARNING"}, "Monitor not registered, nothing to stop")
context.scene.is_monitoring = False
self.report({"INFO"}, "Stopped text block monitoring")
else:
# Start monitoring
bpy.app.timers.register(monitor_text_block)
Expand Down

0 comments on commit ee5ca10

Please sign in to comment.