Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilém Duha <vilda.novak@gmail.com>2020-01-27 20:15:34 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-01-28 15:45:44 +0300
commitf78b7f9618085f35edab46c5a599bdb1c5f843e0 (patch)
tree2b7fe5c3b4777865a4fdd8f319a140b308e5c473 /blenderkit/ui.py
parent4300021a7a8ec4bd092237848daa1ecb96616df7 (diff)
BlenderKit: prevent blender crashes + undo fix
Blender tends to crash during unregistration process when some functions still run (like UI) this is a bug that should be reported, however this fixes the problem at least for BlenderKit now. appending an asset now runs undo push operator with faked context - works surprisingly well. improving lots of tooltips. ratings download license display default sorting by uploaded last
Diffstat (limited to 'blenderkit/ui.py')
-rw-r--r--blenderkit/ui.py40
1 files changed, 38 insertions, 2 deletions
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index f4b64a1f..3f4d0381 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -896,8 +896,12 @@ def draw_callback_2d_search(self, context):
ui_props.mouse_y - linelength, 2, white)
+
def draw_callback_3d(self, context):
''' Draw snapped bbox while dragging and in the future other blenderkit related stuff. '''
+ if not utils.guard_from_crash():
+ return;
+
ui = context.scene.blenderkitUI
if ui.dragging and ui.asset_type == 'MODEL':
@@ -1764,6 +1768,27 @@ class TransferBlenderkitData(bpy.types.Operator):
return {'FINISHED'}
+class UndoWithContext(bpy.types.Operator):
+ """Regenerate cobweb"""
+ bl_idname = "wm.undo_push_context"
+ bl_label = "BlnenderKit undo push"
+ bl_description = "BlenderKit undo push with fixed context"
+ bl_options = {'REGISTER', 'UNDO', 'INTERNAL'}
+
+ # def modal(self, context, event):
+ # return {'RUNNING_MODAL'}
+
+ def execute(self, context):
+ C_dict = bpy.context.copy()
+ C_dict.update(region='WINDOW')
+ if context.area is None or context.area.type != 'VIEW_3D':
+ w, a, r = get_largest_3dview()
+ override = {'window': w, 'screen': w.screen, 'area': a, 'region': r}
+ C_dict.update(override)
+ bpy.ops.ed.undo_push(C_dict, 'INVOKE_REGION_WIN')
+ return {'FINISHED'}
+
+
class RunAssetBarWithContext(bpy.types.Operator):
"""Regenerate cobweb"""
bl_idname = "object.run_assetbar_fix_context"
@@ -1782,18 +1807,28 @@ class RunAssetBarWithContext(bpy.types.Operator):
override = {'window': w, 'screen': w.screen, 'area': a, 'region': r}
C_dict.update(override)
bpy.ops.view3d.blenderkit_asset_bar(C_dict, 'INVOKE_REGION_WIN', keep_running=True, do_search=False)
- return {'RUNNING_MODAL'}
+ return {'FINISHED'}
classess = (
AssetBarOperator,
RunAssetBarWithContext,
- TransferBlenderkitData
+ TransferBlenderkitData,
+ UndoWithContext
)
# store keymap items here to access after registration
addon_keymapitems = []
+#@persistent
+def pre_load(context):
+ ui_props = bpy.context.scene.blenderkitUI
+ ui_props.assetbar_on = False
+ ui_props.turn_off = True
+ preferences = bpy.context.preferences.addons['blenderkit'].preferences
+ preferences.login_attempt = False
+
+
def register_ui():
global handler_2d, handler_3d
@@ -1824,6 +1859,7 @@ def register_ui():
def unregister_ui():
global handler_2d, handler_3d
+ pre_load(bpy.context)
bpy.types.SpaceView3D.draw_handler_remove(handler_2d, 'WINDOW')
bpy.types.SpaceView3D.draw_handler_remove(handler_3d, 'WINDOW')