[Bf-extensions-cvs] [bc464cfc] master: BlenderKit: fix T73507

Vilém Duha noreply at git.blender.org
Fri Apr 3 03:34:52 CEST 2020


Commit: bc464cfc9708ef10fef4f1d5b6afa435067ea11d
Author: Vilém Duha
Date:   Fri Apr 3 03:34:33 2020 +0200
Branches: master
https://developer.blender.org/rBAbc464cfc9708ef10fef4f1d5b6afa435067ea11d

BlenderKit: fix T73507

This could hopefully work. While I managed to finally reproduce the bug, I manged to get it not to happen without actually finding the reason for the keys getting stuck.
The reason seem to be persistent timers.

===================================================================

M	blenderkit/__init__.py
M	blenderkit/bg_blender.py
M	blenderkit/download.py
M	blenderkit/search.py
M	blenderkit/ui.py

===================================================================

diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index 68b2547e..ce9be452 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -92,7 +92,7 @@ def scene_load(context):
     preferences = bpy.context.preferences.addons['blenderkit'].preferences
     preferences.login_attempt = False
 
-
+ at bpy.app.handlers.persistent
 def check_timers_timer():
     ''' checks if all timers are registered regularly. Prevents possible bugs from stopping the addon.'''
     if not bpy.app.timers.is_registered(search.timer_update):
diff --git a/blenderkit/bg_blender.py b/blenderkit/bg_blender.py
index 8a37f6ce..f646636b 100644
--- a/blenderkit/bg_blender.py
+++ b/blenderkit/bg_blender.py
@@ -97,7 +97,7 @@ def progress(text, n=None):
     sys.stdout.flush()
 
 
- at bpy.app.handlers.persistent
+# @bpy.app.handlers.persistent
 def bg_update():
     '''monitoring of background process'''
     text = ''
@@ -232,7 +232,7 @@ def add_bg_process(location=None, name=None, eval_path_computing='', eval_path_s
 
 def register():
     bpy.utils.register_class(KillBgProcess)
-    bpy.app.timers.register(bg_update, persistent=True)
+    bpy.app.timers.register(bg_update)
 
 
 def unregister():
diff --git a/blenderkit/download.py b/blenderkit/download.py
index 82c57235..31b6bae0 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -446,12 +446,12 @@ def append_asset(asset_data, **kwargs):  # downloaders=[], location=None,
     # report_use_success(asset_data['id'])
 
 
- at bpy.app.handlers.persistent
+# @bpy.app.handlers.persistent
 def timer_update():  # TODO might get moved to handle all blenderkit stuff, not to slow down.
     '''check for running and finished downloads and react. write progressbars too.'''
     global download_threads
     if len(download_threads) == 0:
-        return 1
+        return 1.0
     s = bpy.context.scene
     for threaddata in download_threads:
         t = threaddata[0]
@@ -951,7 +951,7 @@ def register_download():
     bpy.utils.register_class(BlenderkitKillDownloadOperator)
     bpy.app.handlers.load_post.append(scene_load)
     bpy.app.handlers.save_pre.append(scene_save)
-    bpy.app.timers.register(timer_update, persistent=True)
+    bpy.app.timers.register(timer_update)
 
 
 def unregister_download():
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 1db1f619..641b1548 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -130,6 +130,7 @@ def fetch_server_data():
 first_time = True
 last_clipboard = ''
 
+
 def check_clipboard():
     # clipboard monitoring to search assets from web
     global last_clipboard
@@ -146,30 +147,34 @@ def check_clipboard():
                 search_props.search_keywords = last_clipboard
                 # don't run search after this - assigning to keywords runs the search_update function.
 
- at bpy.app.handlers.persistent
+
+# @bpy.app.handlers.persistent
 def timer_update():
     # this makes a first search after opening blender. showing latest assets.
     global first_time
     preferences = bpy.context.preferences.addons['blenderkit'].preferences
-    if first_time:# first time
+    if first_time:  # first time
         first_time = False
         if preferences.show_on_start or preferences.first_run:
             # TODO here it should check if there are some results, and only open assetbar if this is the case, not search.
-            #if bpy.context.scene.get('search results') is None:
+            # if bpy.context.scene.get('search results') is None:
             search()
             preferences.first_run = False
         if preferences.tips_on_start:
             ui.get_largest_3dview()
             ui.update_ui_size(ui.active_area, ui.active_region)
             ui.add_report(text='BlenderKit Tip: ' + random.choice(rtips), timeout=12, color=colors.GREEN)
+        return 3.0
 
     check_clipboard()
 
     global search_threads
+    if len(search_threads) == 0:
+        return 1.0
     # don't do anything while dragging - this could switch asset during drag, and make results list length different,
     # causing a lot of throuble.
-    if len(search_threads) == 0 or bpy.context.scene.blenderkitUI.dragging:
-        return 1
+    if bpy.context.scene.blenderkitUI.dragging:
+        return 0.5
     for thread in search_threads:
         # TODO this doesn't check all processes when one gets removed,
         # but most of the time only one is running anyway
@@ -238,7 +243,7 @@ def timer_update():
                             if durl and tname:
 
                                 tooltip = generate_tooltip(r)
-                                #for some reason, the id was still int on some occurances. investigate this.
+                                # for some reason, the id was still int on some occurances. investigate this.
                                 r['author']['id'] = str(r['author']['id'])
 
                                 asset_data = {'thumbnail': tname,
@@ -1207,7 +1212,7 @@ def search_update(self, context):
     ati = kwds.find(atstr)
     # if the asset type already isn't there it means this update function
     # was triggered by it's last iteration and needs to cancel
-    if idi>-1 and ati == -1:
+    if idi > -1 and ati == -1:
         return;
     if ati > -1:
         at = kwds[ati:].lower()
@@ -1293,7 +1298,7 @@ def register_search():
     for c in classes:
         bpy.utils.register_class(c)
 
-    bpy.app.timers.register(timer_update, persistent=True)
+    bpy.app.timers.register(timer_update)
 
     categories.load_categories()
 
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 411e3acf..0ef6ae6d 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -1285,7 +1285,6 @@ class AssetBarOperator(bpy.types.Operator):
             # we check again and quit if things weren't fixed this way.
             if newarea == None:
                 self.exit_modal()
-                ui_props.assetbar_on = False
                 return {'CANCELLED'}
 
         update_ui_size(self.area, self.region)
@@ -1306,7 +1305,6 @@ class AssetBarOperator(bpy.types.Operator):
         s = context.scene
 
         if ui_props.turn_off:
-            ui_props.assetbar_on = False
             ui_props.turn_off = False
             self.exit_modal()
             ui_props.draw_tooltip = False



More information about the Bf-extensions-cvs mailing list