From 1d0b233f12e937f6278fc38775fca530e2be2661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Sat, 2 May 2020 22:36:46 +0200 Subject: Qt: Stretch last packet list header section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ń Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke Reviewed-by: Anders Broman --- ui/qt/main_window_layout.cpp | 4 ++++ ui/qt/packet_list.cpp | 4 ++-- ui/qt/widgets/packet_list_header.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/ui/qt/main_window_layout.cpp b/ui/qt/main_window_layout.cpp index a465a3cde3..0707a35382 100644 --- a/ui/qt/main_window_layout.cpp +++ b/ui/qt/main_window_layout.cpp @@ -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) { diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index aa7b197473..d936925a8f 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -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. diff --git a/ui/qt/widgets/packet_list_header.cpp b/ui/qt/widgets/packet_list_header.cpp index e08469e2d7..251fc4e44c 100644 --- a/ui/qt/widgets/packet_list_header.cpp +++ b/ui/qt/widgets/packet_list_header.cpp @@ -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); } -- cgit v1.2.3