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.
This commit is contained in:
Ryan Roden-Corrent 2017-07-24 08:14:34 -04:00
parent b7fe13434b
commit f09423efe5
2 changed files with 7 additions and 0 deletions

View File

@ -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]

View File

@ -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)