Qt: Stretch last packet list header section

Programatically show the master split widget before elements are added
to prevent pending resize events from resizing packet columns to insane
widths (in my case orders of magnitude higher than display resolution)

Such resize was occuring when loading capture file if configuration file
included hidden columns (e.g. 55 defined columns, 8 visible). The resize
was not directly visible to user. Resize event call chain included calls
to recent_set_column_width() that changed width stored in configuration.
Modified configuration column width value would become effective after
user added or removed columns.

Hide PacketList when freezing and show it when thawing. Do not call
setUpdatesEnabled(false) as it leads to widget/preferences columns
missynchronization.

Clear packet list before freeing frame data. This prevents accessing
freed memory in ProtoTree on file close if packet list was in focus and
the next widget to get focus is packet details.

Ping-Bug: 16063
Bug: 16491
Change-Id: I2c21d928348681af1793b3263815c81ee73d41b0
Reviewed-on: https://code.wireshark.org/review/37029
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Tomasz Moń 2020-05-02 22:36:46 +02:00 committed by Anders Broman
parent f399d135e0
commit 1d0b233f12
4 changed files with 12 additions and 8 deletions

10
file.c
View File

@ -378,6 +378,11 @@ cf_close(capture_file *cf)
/* Clean up the record metadata. */
wtap_rec_cleanup(&cf->rec);
/* Clear the packet list. */
packet_list_freeze();
packet_list_clear();
packet_list_thaw();
/* Free up the packet buffer. */
ws_buffer_free(&cf->buf);
@ -407,11 +412,6 @@ cf_close(capture_file *cf)
cf->linktypes = NULL;
}
/* Clear the packet list. */
packet_list_freeze();
packet_list_clear();
packet_list_thaw();
cf->f_datalen = 0;
nstime_set_zero(&cf->elapsed_time);

View File

@ -91,6 +91,10 @@ void MainWindow::layoutPanes()
empty_pane_.setParent(main_ui_->mainStack);
extra_split_.setParent(main_ui_->mainStack);
// Show the master splitter here to prevent pending resize events changing packet list columns
// when the master splitter is set as current widget for the first time.
master_split_.show();
// XXX We should try to preserve geometries if we can, e.g. by
// checking to see if the layout type is the same.
switch(prefs.gui_layout_type) {

View File

@ -1169,8 +1169,8 @@ void PacketList::captureFileReadFinished()
void PacketList::freeze()
{
setUpdatesEnabled(false);
column_state_ = header()->saveState();
setVisible(false);
if (currentIndex().isValid()) {
frozen_row_ = currentIndex().row();
} else {
@ -1188,7 +1188,7 @@ void PacketList::freeze()
void PacketList::thaw(bool restore_selection)
{
setUpdatesEnabled(true);
setVisible(true);
setModel(packet_list_model_);
// Resetting the model resets our column widths so we restore them here.

View File

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