summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-11-02 17:52:26 +0100
committerFlorian Bruhin <me@the-compiler.org>2020-11-02 17:57:36 +0100
commit9a1a2461fb93d22fbec1d230416e1e2ce4fd56b5 (patch)
tree5cc1154fb2ef84fd2459088e7acec60ca8eb4a4f
parent0918c9e85eb8606f33d069ee87e49299e0092e8b (diff)
downloadqutebrowser-9a1a2461fb93d22fbec1d230416e1e2ce4fd56b5.tar.gz
qutebrowser-9a1a2461fb93d22fbec1d230416e1e2ce4fd56b5.zip
Fix objreg.first/last_opened_window w/o windows
Before 4cd255c7372625b4c3a630844ffd2b42d6ddde58, we correctly raised `NoWindow()` via `_window_by_index(-1)`. After this change, `first_opened_window` and `last_opened_window()` didn't do anything at all, because their for-loop iterated over an empty range, thus causing the `Unreachable` to be hit. This caused #1246 to manifest in a different way than usual. Now, we're back to the old (still buggy) behavior in that case. Closes #5849 (cherry picked from commit 18750a332a5474fe42bcdefcf14cea10eec41243)
-rw-r--r--qutebrowser/utils/objreg.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/qutebrowser/utils/objreg.py b/qutebrowser/utils/objreg.py
index 587b59629..344b3d660 100644
--- a/qutebrowser/utils/objreg.py
+++ b/qutebrowser/utils/objreg.py
@@ -350,6 +350,8 @@ def _window_by_index(idx: int) -> 'mainwindow.MainWindow':
def last_opened_window() -> 'mainwindow.MainWindow':
"""Get the last opened window object."""
+ if not window_registry:
+ raise NoWindow()
for idx in range(-1, -(len(window_registry)+1), -1):
window = _window_by_index(idx)
if not window.tabbed_browser.is_shutting_down:
@@ -359,6 +361,8 @@ def last_opened_window() -> 'mainwindow.MainWindow':
def first_opened_window() -> 'mainwindow.MainWindow':
"""Get the first opened window object."""
+ if not window_registry:
+ raise NoWindow()
for idx in range(0, len(window_registry)+1):
window = _window_by_index(idx)
if not window.tabbed_browser.is_shutting_down: