mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #1645 from pypeclub/bugfix/replace_blocking_queue
This commit is contained in:
commit
f8e1d5095d
1 changed files with 19 additions and 16 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import collections
|
||||
import copy
|
||||
import json
|
||||
from queue import Queue
|
||||
from uuid import uuid4
|
||||
|
||||
from .constants import (
|
||||
|
|
@ -160,6 +159,10 @@ class HierarchyModel(QtCore.QAbstractItemModel):
|
|||
if self._current_project == project_name and not force:
|
||||
return
|
||||
|
||||
# Reset attributes
|
||||
self._items_by_id.clear()
|
||||
self._asset_items_by_name.clear()
|
||||
|
||||
self.clear()
|
||||
|
||||
self._current_project = project_name
|
||||
|
|
@ -219,13 +222,13 @@ class HierarchyModel(QtCore.QAbstractItemModel):
|
|||
parent_id = asset_doc["data"].get("visualParent")
|
||||
asset_docs_by_parent_id[parent_id].append(asset_doc)
|
||||
|
||||
appending_queue = Queue()
|
||||
appending_queue.put((None, project_item))
|
||||
appending_queue = collections.deque()
|
||||
appending_queue.append((None, project_item))
|
||||
|
||||
asset_items_by_id = {}
|
||||
non_modifiable_items = set()
|
||||
while not appending_queue.empty():
|
||||
parent_id, parent_item = appending_queue.get()
|
||||
while appending_queue:
|
||||
parent_id, parent_item = appending_queue.popleft()
|
||||
asset_docs = asset_docs_by_parent_id.get(parent_id) or []
|
||||
|
||||
new_items = []
|
||||
|
|
@ -242,19 +245,19 @@ class HierarchyModel(QtCore.QAbstractItemModel):
|
|||
|
||||
asset_items_by_id[asset_id] = new_item
|
||||
# Add item to appending queue
|
||||
appending_queue.put((asset_id, new_item))
|
||||
appending_queue.append((asset_id, new_item))
|
||||
|
||||
if new_items:
|
||||
self.add_items(new_items, parent_item)
|
||||
|
||||
# Handle Asset's that are not modifiable
|
||||
# - pass the information to all it's parents
|
||||
non_modifiable_queue = Queue()
|
||||
non_modifiable_queue = collections.deque()
|
||||
for item_id in non_modifiable_items:
|
||||
non_modifiable_queue.put(item_id)
|
||||
non_modifiable_queue.append(item_id)
|
||||
|
||||
while not non_modifiable_queue.empty():
|
||||
item_id = non_modifiable_queue.get()
|
||||
while non_modifiable_queue:
|
||||
item_id = non_modifiable_queue.popleft()
|
||||
item = self._items_by_id[item_id]
|
||||
item.setData(False, HIERARCHY_CHANGE_ABLE_ROLE)
|
||||
|
||||
|
|
@ -264,7 +267,7 @@ class HierarchyModel(QtCore.QAbstractItemModel):
|
|||
and parent.id not in non_modifiable_items
|
||||
):
|
||||
non_modifiable_items.add(parent.id)
|
||||
non_modifiable_queue.put(parent.id)
|
||||
non_modifiable_queue.append(parent.id)
|
||||
|
||||
# Add task items
|
||||
for asset_id, asset_item in asset_items_by_id.items():
|
||||
|
|
@ -1130,18 +1133,18 @@ class HierarchyModel(QtCore.QAbstractItemModel):
|
|||
project_name = project_item.name
|
||||
project_col = self.dbcon.database[project_name]
|
||||
|
||||
to_process = Queue()
|
||||
to_process.put(project_item)
|
||||
to_process = collections.deque()
|
||||
to_process.append(project_item)
|
||||
|
||||
bulk_writes = []
|
||||
while not to_process.empty():
|
||||
parent = to_process.get()
|
||||
while to_process:
|
||||
parent = to_process.popleft()
|
||||
insert_list = []
|
||||
for item in parent.children():
|
||||
if not isinstance(item, AssetItem):
|
||||
continue
|
||||
|
||||
to_process.put(item)
|
||||
to_process.append(item)
|
||||
|
||||
if item.is_new:
|
||||
insert_list.append(item)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue