Qt: Fix invalid pointer for model

Ideally it should never happen, that the model is being queried
outside it's scope, which is ONLY the PacketList. MainWindow is
the last place where such queries should happen. In the meantime
a check for invalid model is being added.

Bug: 16065
Change-Id: I9a3fa39333d55dbbb7ebcac87f39da7bd8547486
Reviewed-on: https://code.wireshark.org/review/34591
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Roland Knall 2019-09-22 14:56:46 +02:00 committed by Peter Wu
parent 7d874e2d3c
commit b43177e1f0
1 changed files with 4 additions and 2 deletions

View File

@ -1967,7 +1967,7 @@ void MainWindow::on_actionEditCopyAsFilter_triggered()
void MainWindow::on_actionEditFindPacket_triggered()
{
if (packet_list_->model()->rowCount() < 1) {
if (! packet_list_->model() || packet_list_->model()->rowCount() < 1) {
return;
}
previous_focus_ = wsApp->focusWidget();
@ -2453,6 +2453,8 @@ void MainWindow::on_actionViewResetLayout_triggered()
void MainWindow::on_actionViewResizeColumns_triggered()
{
if ( ! packet_list_->model() )
return;
for (int col = 0; col < packet_list_->model()->columnCount(); col++) {
packet_list_->resizeColumnToContents(col);
recent_set_column_width(col, packet_list_->columnWidth(col));
@ -3413,7 +3415,7 @@ void MainWindow::on_actionHelpAbout_triggered()
}
void MainWindow::on_actionGoGoToPacket_triggered() {
if (packet_list_->model()->rowCount() < 1) {
if (! packet_list_->model() || packet_list_->model()->rowCount() < 1) {
return;
}
previous_focus_ = wsApp->focusWidget();