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:
authorPeter Kim <pk15950@gmail.com>2021-07-29 07:14:36 +0300
committerPeter Kim <pk15950@gmail.com>2021-07-29 07:14:36 +0300
commitb01ba8a1e4a920ca2610a0db7c39710e8eabe9df (patch)
treefdcb811048cf4a0ec3ef14ec4d459ec70df534d8
parent62da286fc85e2bf775a2c4e98056e2b07877f9aa (diff)
parentde28e1da320fab72bf0fa1334a20202024b2525b (diff)
Merge branch 'master' into xr-controller-support
-rw-r--r--blenderkit/search.py45
-rw-r--r--blenderkit/ui.py9
2 files changed, 15 insertions, 39 deletions
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 6bbbac7f..e797314d 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -674,15 +674,17 @@ def thumb_download_worker(queue_sml, queue_full):
# utils.p('start thumbdownloader thread')
while 1:
session = None
- #start a session only for single search usually.
+ #start a session only for single search usually, if users starts scrolling, the session might last longer if
+ # queue gets filled.
if not queue_sml.empty() or not queue_full.empty():
- session = requests.Session()
-
+ if session is None:
+ session = requests.Session()
while not queue_sml.empty():
+ #first empty the small thumbs queue
url, filepath = queue_sml.get()
download_image(session,url, filepath)
exit_full = False
- # download full resolution image, but only if no small thumbs are waiting.
+ # download full resolution image, but only if no small thumbs are waiting. If there are small
while not queue_full.empty() and queue_sml.empty():
url, filepath = queue_full.get()
download_image(session,url, filepath)
@@ -690,41 +692,9 @@ def thumb_download_worker(queue_sml, queue_full):
if queue_sml.empty() and queue_full.empty():
if session is not None:
session.close()
+ session = None
time.sleep(.5)
-class ThumbDownloader(threading.Thread):
-
- def __init__(self, url, path, session):
- super(ThumbDownloader, self).__init__()
- self.url = url
- self.path = path
- self.session = session
- self._stop_event = threading.Event()
-
- def stop(self):
- self._stop_event.set()
-
- def stopped(self):
- return self._stop_event.is_set()
-
- def run(self):
- # print('thumb downloader', self.url)
- # utils.p('start thumbdownloader thread')
- r = None
- try:
- r = self.session.get(self.url, stream=False)
- except Exception as e:
- bk_logger.error('Thumbnail download failed')
- bk_logger.error(str(e))
- if r and r.status_code == 200:
- with open(self.path, 'wb') as f:
- f.write(r.content)
- # ORIGINALLY WE DOWNLOADED THUMBNAILS AS STREAM, BUT THIS WAS TOO SLOW.
- # with open(path, 'wb') as f:
- # for chunk in r.iter_content(1048576*4):
- # f.write(chunk)
- # utils.p('end thumbdownloader thread')
-
def write_gravatar(a_id, gravatar_path):
'''
@@ -1265,7 +1235,6 @@ def add_search_process(query, params):
if thumb_workers_sml == []:
for a in range(0, 8):
- # worker = ThumbDownloadWorker(thumb_sml_download_threads, thumb_full_download_threads)
thread = threading.Thread(target=thumb_download_worker, args=(thumb_sml_download_threads, thumb_full_download_threads),
daemon=True)
thread.start()
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 138f4a89..bf6ea546 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -1776,6 +1776,8 @@ class AssetDragOperator(bpy.types.Operator):
(abs(self.start_mouse_x - self.mouse_x) > drag_threshold or \
abs(self.start_mouse_y - self.mouse_y) > drag_threshold):
self.drag = True
+
+ if self.drag and ui_props.assetbar_on:
# turn off asset bar here, shout start again after finishing drag drop.
ui_props.turn_off = True
@@ -1819,7 +1821,7 @@ class AssetDragOperator(bpy.types.Operator):
if ui_props.asset_type == 'MODEL':
self.snapped_bbox_min = Vector(self.asset_data['bbox_min'])
self.snapped_bbox_max = Vector(self.asset_data['bbox_max'])
- return {'RUNNING_MODAL'}
+ #return {'RUNNING_MODAL'}
if event.type == 'LEFTMOUSE' and event.value == 'RELEASE':
self.mouse_release() # does the main job with assets
@@ -1829,8 +1831,13 @@ class AssetDragOperator(bpy.types.Operator):
bpy.ops.object.run_assetbar_fix_context(keep_running=True, do_search=False)
ui_props.dragging = False
return {'FINISHED'}
+
self.steps += 1
+ #pass event to assetbar so it can close itself
+ if ui_props.assetbar_on and ui_props.turn_off:
+ return {'PASS_THROUGH'}
+
return {'RUNNING_MODAL'}
def invoke(self, context, event):