diff options
author | Jason Rosenzweig <mail4jasonr@gmail.com> | 2021-06-03 09:20:17 +0800 |
---|---|---|
committer | Jason Rosenzweig <mail4jasonr@gmail.com> | 2021-06-03 09:20:17 +0800 |
commit | 4be22297608acb7058d0a489841a013b3263dae4 (patch) | |
tree | 8609c71a8c6ec064eebb46c2ade7791d3ad88333 /qutebrowser/mainwindow | |
parent | f713421b8887f72dd8116054f86575c7607b6a7d (diff) | |
download | qutebrowser-4be22297608acb7058d0a489841a013b3263dae4.tar.gz qutebrowser-4be22297608acb7058d0a489841a013b3263dae4.zip |
Fixed crash when directory does not exist
Diffstat (limited to 'qutebrowser/mainwindow')
-rw-r--r-- | qutebrowser/mainwindow/prompt.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index 610b274c4..915d6b3f9 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -663,19 +663,21 @@ class FilenamePrompt(_BasePrompt): root = self._file_model.setRootPath(path) self._file_view.setRootIndex(root) - - # Iterate over all directories in the current root path to see if the input is a substring - for currentDir in os.listdir(path): - currentDir = os.path.join(path, currentDir) - - if basename not in os.path.basename(currentDir): - index = self._file_model.index(currentDir) - self._file_view.setRowHidden(index.row(), index.parent(), True) - else: - index = self._file_model.index(currentDir) - self._file_view.setRowHidden(index.row(), index.parent(), False) - - self._file_view.setModel(self._file_model) + try: + # Iterate over all directories in the current root path to see if the input is a substring + for currentDir in os.listdir(path): + currentDir = os.path.join(path, currentDir) + + if basename not in os.path.basename(currentDir): + index = self._file_model.index(currentDir) + self._file_view.setRowHidden(index.row(), index.parent(), True) + else: + index = self._file_model.index(currentDir) + self._file_view.setRowHidden(index.row(), index.parent(), False) + + self._file_view.setModel(self._file_model) + except FileNotFoundError: + log.prompt.exception("Directory doesn't exist, can't hide and unhide file prompt folders") @pyqtSlot(QModelIndex) def _insert_path(self, index, *, clicked=True): |