Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder widget: Fix set selected folder path #719

Merged

Conversation

BigRoy
Copy link
Collaborator

@BigRoy BigRoy commented Jun 27, 2024

Changelog Description

Fix the logic to set selected folder path in Folder Widget

Additional info

Stack trace:

Traceback (most recent call last):
  File "E:\dev\ayon-core\server_addon\houdini\client\ayon_houdini\api\hda_utils.py", line 519, in _select_folder_path
    dialog.folder_widget.set_selected_folder_path(folder_path)
  File "E:\dev\ayon-core\client\ayon_core\tools\utils\folders_widget.py", line 561, in set_selected_folder_path
    folder_id = self._folders_model.get_item_id_by_path(folder_path)
  File "E:\dev\ayon-core\client\ayon_core\tools\utils\folders_widget.py", line 99, in get_item_id_by_path
    for folder_id, item in self._items_by_id.values():
TypeError: cannot unpack non-iterable PySide2.QtGui.QStandardItem object

Testing notes:

  1. Folder Widget should work.

Ugly testing code:

from ayon_core.tools.utils.folders_widget import SimpleFoldersWidget

from ayon_core.pipeline import (
    get_current_project_name,
    get_current_folder_path
)
from qtpy import QtCore, QtWidgets


class Dialog(QtWidgets.QDialog):
    def __init__(self):
        super().__init__()
        
        layout = QtWidgets.QVBoxLayout(self)
        widget = SimpleFoldersWidget(parent=self)
        layout.addWidget(widget)
        
        self.folders_widget = widget
        
dialog = Dialog()
dialog.show()

dialog.folders_widget.set_project_name(get_current_project_name())

# This should not error (it does not actually work, because the above set project has a small delay)
dialog.folders_widget.set_selected_folder_path(get_current_folder_path())

# This would work directly though
QtCore.QTimer.singleShot(100, lambda: dialog.folders_widget.set_selected_folder_path(get_current_folder_path()))

@BigRoy BigRoy requested a review from iLLiCiTiT June 27, 2024 13:43
@ynbot ynbot added size/XS type: bug Something isn't working labels Jun 27, 2024
@iLLiCiTiT iLLiCiTiT changed the title Core: Fix folder widget set selected folder path Folder widget: Fix set selected folder path Jun 27, 2024
@iLLiCiTiT iLLiCiTiT merged commit 342192c into ynput:develop Jun 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants