enthought / pyface

pyface: traits-capable windowing framework
Other
105 stars 55 forks source link

Bug report: FileDialog and DirectoryDialog raise AttributeError when closed using the "X" button #1158

Closed nicolasap-dm closed 1 year ago

nicolasap-dm commented 1 year ago

Environment

OS: Linux Python version: 3.6 Toolkit: Qt Qt API: PySide2

Description

Opening a FileDialog or DirectoryDialog and clicking "X" in the file picker that appears, generates a traceback.

Traceback (most recent call last):
  File "mwe.py", line 5, in <module>
    outcome = dlg.open()
  File "/.../lib/python3.6/site-packages/pyface/i_dialog.py", line 168, in open
    self.close()
  File "/.../lib/python3.6/site-packages/pyface/ui/qt4/directory_dialog.py", line 55, in close
    files = self.control.selectedFiles()
AttributeError: 'NoneType' object has no attribute 'selectedFiles'

Clicking, instead, the "Cancel" button, correctly returns CANCEL.

Steps to Reproduce

dlg = DirectoryDialog(parent=None, title="Select a folder")
outcome = dlg.open()