Qt: Work around QTBUG-122109 when applying packet list style sheet

https://bugreports.qt.io/browse/QTBUG-122109

A bug introduced by the fix for https://bugreports.qt.io/browse/QTBUG-116013
causes all visible sections to reset to the default section size whenever a
style sheet is applied (even if defaultSectionSize didn't change.)

Make sure that before applying a style sheet we prevent our recent
column widths from being updated, and then restore column widths
from the recent values afterwards.

This affects versions 6.5.4 (commercial only, 6.5.3 is the last free
release) and 6.6.1 and 6.6.2.
This commit is contained in:
John Thacker 2024-02-22 08:54:12 -05:00
parent e5e0797bd5
commit ea38f142e8
2 changed files with 19 additions and 1 deletions

View File

@ -227,6 +227,7 @@ PacketList::PacketList(QWidget *parent) :
tail_at_end_(0),
columns_changed_(false),
set_column_visibility_(false),
set_style_sheet_(false),
frozen_current_row_(QModelIndex()),
frozen_selected_rows_(QModelIndexList()),
cur_history_(-1),
@ -392,11 +393,27 @@ void PacketList::colorsChanged()
}
// Set the style sheet
set_style_sheet_ = true;
if(prefs.gui_packet_list_hover_style) {
setStyleSheet(active_style + inactive_style + hover_style);
} else {
setStyleSheet(active_style + inactive_style);
}
set_style_sheet_ = false;
#if \
( \
(QT_VERSION >= QT_VERSION_CHECK(6, 5, 4) && QT_VERSION < QT_VERSION_CHECK(6, 6, 0)) \
|| (QT_VERSION >= QT_VERSION_CHECK(6, 6, 1)) \
)
// https://bugreports.qt.io/browse/QTBUG-122109
// Affects Qt 6.5.4 and later, 6.6.1 and later.
// When setting the style sheet, all visible sections are set
// to the new minimum DefaultSectionSize (even if it hasn't
// changed.) So make sure the new widths aren't saved to recent
// and then restore from recent.
applyRecentColumnWidths();
setColumnVisibility();
#endif
}
QString PacketList::joinSummaryRow(QStringList col_parts, int row, SummaryCopyType type)
@ -1803,7 +1820,7 @@ void PacketList::columnVisibilityTriggered()
void PacketList::sectionResized(int col, int, int new_width)
{
if (isVisible() && !columns_changed_ && !set_column_visibility_ && new_width > 0) {
if (isVisible() && !columns_changed_ && !set_column_visibility_ && !set_style_sheet_ && new_width > 0) {
// Column 1 gets an invalid value (32 on macOS) when we're not yet
// visible.
//

View File

@ -141,6 +141,7 @@ private:
bool tail_at_end_;
bool columns_changed_;
bool set_column_visibility_;
bool set_style_sheet_;
QModelIndex frozen_current_row_;
QModelIndexList frozen_selected_rows_;
QVector<int> selection_history_;