mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
breadcrumbs are not brute focing access to child entities by accessing with __getitem__ but checking if 'has_child_with_key'
This commit is contained in:
parent
16ae291386
commit
06fed885ad
1 changed files with 25 additions and 6 deletions
|
|
@ -71,17 +71,35 @@ class SettingsBreadcrumbs(BreadcrumbsModel):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_valid_path(self, path):
|
||||||
|
if not path:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
path_items = path.split("/")
|
||||||
|
new_path_items = []
|
||||||
|
entity = self.entity
|
||||||
|
for item in path_items:
|
||||||
|
if not entity.has_child_with_key(item):
|
||||||
|
break
|
||||||
|
|
||||||
|
new_path_items.append(item)
|
||||||
|
entity = entity[item]
|
||||||
|
|
||||||
|
return "/".join(new_path_items)
|
||||||
|
|
||||||
def is_valid_path(self, path):
|
def is_valid_path(self, path):
|
||||||
if not path:
|
if not path:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
path_items = path.split("/")
|
path_items = path.split("/")
|
||||||
try:
|
|
||||||
entity = self.entity
|
entity = self.entity
|
||||||
for item in path_items:
|
for item in path_items:
|
||||||
entity = entity[item]
|
if not entity.has_child_with_key(item):
|
||||||
except Exception:
|
return False
|
||||||
return False
|
|
||||||
|
entity = entity[item]
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -436,6 +454,7 @@ class BreadcrumbsAddressBar(QtWidgets.QFrame):
|
||||||
self.change_path(path)
|
self.change_path(path)
|
||||||
|
|
||||||
def change_path(self, path):
|
def change_path(self, path):
|
||||||
|
path = self._model.get_valid_path(path)
|
||||||
if self._model and not self._model.is_valid_path(path):
|
if self._model and not self._model.is_valid_path(path):
|
||||||
self._show_address_field()
|
self._show_address_field()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue