diff options
author | Vilem Duha <vilem.duha@gmail.com> | 2019-04-04 01:34:43 +0300 |
---|---|---|
committer | Vilem Duha <vilem.duha@gmail.com> | 2019-04-04 01:34:43 +0300 |
commit | 449e2c4072d507c873d0a6246f401293a9abad3c (patch) | |
tree | 0534777379a6e6a7e0dafe74844db9176126559e /blenderkit | |
parent | c3c7663ed4e7c8d5e5cb1bdb6ee20c7ed19d47a5 (diff) |
BlenderKit: fix unregister - removing draw progress handlers
Diffstat (limited to 'blenderkit')
-rw-r--r-- | blenderkit/ui.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/blenderkit/ui.py b/blenderkit/ui.py index 4973b6c3..7d0a3573 100644 --- a/blenderkit/ui.py +++ b/blenderkit/ui.py @@ -42,6 +42,9 @@ from mathutils import Vector import time import os +handler_2d = None +handler_3d = None + mappingdict = { 'MODEL': 'model', 'SCENE': 'scene', @@ -1132,7 +1135,7 @@ class AssetBarOperator(bpy.types.Operator): if ui_props.has_hit and ui_props.asset_type == 'MODEL': # this condition is here to fix a bug for a scene submitted by a user, so this situation shouldn't # happen anymore, but there might exists scenes which have this problem for some reason. - if ui_props.active_index<len(sr) and ui_props.active_index>-1: + if ui_props.active_index < len(sr) and ui_props.active_index > -1: ui_props.draw_snapped_bounds = True active_mod = sr[ui_props.active_index] ui_props.snapped_bbox_min = Vector(active_mod['bbox_min']) @@ -1338,7 +1341,7 @@ class AssetBarOperator(bpy.types.Operator): pass return {'FINISHED'} - ui_props.dragging = False #only for cases where assetbar ended with an error. + ui_props.dragging = False # only for cases where assetbar ended with an error. ui_props.assetbar_on = True ui_props.turn_off = False @@ -1383,12 +1386,15 @@ addon_keymaps = [] def register_ui(): + global handler_2d, handler_3d + for c in classess: bpy.utils.register_class(c) args = (None, bpy.context) - bpy.types.SpaceView3D.draw_handler_add(draw_callback_2d_progress, args, 'WINDOW', 'POST_PIXEL') - bpy.types.SpaceView3D.draw_handler_add(draw_callback_3d_progress, args, 'WINDOW', 'POST_VIEW') + + handler_2d = bpy.types.SpaceView3D.draw_handler_add(draw_callback_2d_progress, args, 'WINDOW', 'POST_PIXEL') + handler_3d = bpy.types.SpaceView3D.draw_handler_add(draw_callback_3d_progress, args, 'WINDOW', 'POST_VIEW') wm = bpy.context.window_manager @@ -1404,16 +1410,16 @@ def register_ui(): def unregister_ui(): + global handler_2d, handler_3d + for c in classess: bpy.utils.unregister_class(c) args = (None, bpy.context) - try: - bpy.types.SpaceView3D.draw_handler_remove(draw_callback_2d_progress, args, 'WINDOW', 'POST_PIXEL') - bpy.types.SpaceView3D.draw_handler_remove(draw_callback_3d_progress, args, 'WINDOW', 'POST_VIEW') - except: - print('handlers allready removed') + bpy.types.SpaceView3D.draw_handler_remove(handler_2d, 'WINDOW') + bpy.types.SpaceView3D.draw_handler_remove(handler_3d, 'WINDOW') + wm = bpy.context.window_manager if not wm.keyconfigs.addon: return |