Merge branch 'master' into xr-controller-support

This commit is contained in:
Peter Kim 2021-07-29 13:14:36 +09:00
commit b01ba8a1e4
2 changed files with 15 additions and 39 deletions

View File

@ -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()

View File

@ -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):