diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-11 17:26:30 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-11 17:26:30 +0200 |
commit | ef23ed7ef18c7a0e413a753304d159aa1da7051c (patch) | |
tree | 00b0405205ddc991162b8729b64bcc20b7209bb0 /LibGUI/GTableView.cpp | |
parent | f52e66ceda910ce4e86360de0cf5a3bc98ab4083 (diff) | |
download | serenity-ef23ed7ef18c7a0e413a753304d159aa1da7051c.zip |
GTableView: Handle not having a model a bit more gracefully.
Diffstat (limited to 'LibGUI/GTableView.cpp')
-rw-r--r-- | LibGUI/GTableView.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/LibGUI/GTableView.cpp b/LibGUI/GTableView.cpp index 4a29e269a4..7ba3977cf3 100644 --- a/LibGUI/GTableView.cpp +++ b/LibGUI/GTableView.cpp @@ -65,6 +65,9 @@ Rect GTableView::header_rect(int column_index) const void GTableView::mousedown_event(GMouseEvent& event) { + if (!model()) + return; + if (event.y() < header_height()) { auto adjusted_position = event.position().translated(horizontal_scrollbar().value(), 0); for (int i = 0; i < model()->column_count(); ++i) { @@ -100,6 +103,9 @@ void GTableView::paint_event(GPaintEvent& event) { GFrame::paint_event(event); + if (!model()) + return; + GPainter painter(*this); painter.add_clip_rect(frame_inner_rect()); painter.add_clip_rect(event.rect()); @@ -213,6 +219,8 @@ void GTableView::paint_headers(Painter& painter) int GTableView::item_count() const { + if (!model()) + return 0; return model()->row_count(); } |