Qt: Fix bug causing hidden columns to be displayed

Set capture file for model and header before columnsChanged() is called
to prevent skipping model reset in PacketListModel::resetColumns() due
to cap_file_ being NULL.

Do not strech last section in packet list header. This prevents
QHeaderViewPrivate::resizeSections() from messing up the column sizes
via resize events. For some reason (unknown to me) underlying
QHeaderView implementation has different idea about the number of
visible columns than our code.

Ping-Bug: 16063
Change-Id: I482c1080adb418b7922ee99d357d4962dc086026
Reviewed-on: https://code.wireshark.org/review/36120
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Tomasz Moń 2020-02-16 12:43:11 +01:00 committed by Roland Knall
parent 0039505dd1
commit 1d20a875e4
3 changed files with 4 additions and 5 deletions

View File

@ -109,7 +109,6 @@ PacketListModel::~PacketListModel()
void PacketListModel::setCaptureFile(capture_file *cf)
{
cap_file_ = cf;
resetColumns();
}
// Packet list records have no children (for now, at least).

View File

@ -1059,7 +1059,7 @@ void PacketList::fieldsChanged(capture_file *cf)
prefs.num_cols = g_list_length(prefs.col_list);
col_cleanup(&cf->cinfo);
build_column_format_array(&cf->cinfo, prefs.num_cols, FALSE);
// call packet_list_model_->resetColumns() ?
resetColumns();
}
// Column widths should
@ -1440,6 +1440,8 @@ void PacketList::deleteAllPacketComments()
void PacketList::setCaptureFile(capture_file *cf)
{
cap_file_ = cf;
packet_list_model_->setCaptureFile(cf);
packet_list_header_->setCaptureFile(cf);
if (cf) {
if (columns_changed_) {
columnsChanged();
@ -1449,8 +1451,6 @@ void PacketList::setCaptureFile(capture_file *cf)
setColumnVisibility();
}
}
packet_list_model_->setCaptureFile(cf);
packet_list_header_->setCaptureFile(cf);
create_near_overlay_ = true;
sortByColumn(-1, Qt::AscendingOrder);
}

View File

@ -36,7 +36,7 @@ PacketListHeader::PacketListHeader(Qt::Orientation orientation, capture_file * c
{
setAcceptDrops(true);
setSectionsMovable(true);
setStretchLastSection(true);
setStretchLastSection(false);
setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter);
}