From f09423efe5871e48c70aede659395743f668672a Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Mon, 24 Jul 2017 08:14:34 -0400 Subject: [PATCH] Abort resizeEvent if model is None. Some reports came in that a resizeEvent was causing a crash due to the model being none in the CompletionView. Fixes #2854. --- qutebrowser/completion/completionwidget.py | 2 ++ tests/unit/completion/test_completionwidget.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 65f1de76c..4674beb69 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -148,6 +148,8 @@ class CompletionView(QTreeView): def _resize_columns(self): """Resize the completion columns based on column_widths.""" + if self.model() is None: + return width = self.size().width() column_widths = self.model().column_widths pixel_widths = [(width * perc // 100) for perc in column_widths] diff --git a/tests/unit/completion/test_completionwidget.py b/tests/unit/completion/test_completionwidget.py index 22d150fd8..2d4c8e744 100644 --- a/tests/unit/completion/test_completionwidget.py +++ b/tests/unit/completion/test_completionwidget.py @@ -240,3 +240,8 @@ def test_completion_item_del_no_selection(completionview): with pytest.raises(cmdexc.CommandError, match='No item selected!'): completionview.completion_item_del() assert not func.called + + +def test_resize_no_model(completionview, qtbot): + """Ensure no crash if resizeEvent is triggered with no model (#2854).""" + completionview.resizeEvent(None)