Qt: Column preference fixes.

Don't call redrawVisiblePackets in PacketList::sectionResized. Otherwise
we trigger the crash in bug 11179. Call recent_set_column_width instead.

Clean up the slots called when column preferences change and when recent
column widths change.

Update our column visibility in redrawVisiblePackets.

Use recent_get_column_width when writing the recent file. columnWidth
doesn't return a valid value when we're not visible.

Bug: 11179.
Change-Id: I34ab93d944b341e42129a1c8ff94ba8f7ad4f5fc
Reviewed-on: https://code.wireshark.org/review/8457
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2015-05-13 15:46:51 -07:00
parent 2793069020
commit 2156413bf9
5 changed files with 19 additions and 18 deletions

View File

@ -326,8 +326,10 @@ MainWindow::MainWindow(QWidget *parent) :
connect(&capture_file_, SIGNAL(captureFileReadFinished()),
wsApp, SLOT(updateTaps()));
connect(wsApp, SIGNAL(columnsChanged()),
connect(wsApp, SIGNAL(recentFilesRead()),
packet_list_, SLOT(applyRecentColumnWidths()));
connect(wsApp, SIGNAL(columnsChanged()),
packet_list_, SLOT(redrawVisiblePackets()));
connect(wsApp, SIGNAL(recentFilesRead()),
this, SLOT(applyRecentPaneGeometry()));
connect(wsApp, SIGNAL(packetDissectionChanged()),

View File

@ -2111,6 +2111,7 @@ void MainWindow::on_actionViewResizeColumns_triggered()
{
for (int col = 0; col < packet_list_->packetListModel()->columnCount(); col++) {
packet_list_->resizeColumnToContents(col);
recent_set_column_width(col, packet_list_->columnWidth(col));
}
}

View File

@ -417,8 +417,9 @@ PacketList::PacketList(QWidget *parent) :
header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header(), SIGNAL(customContextMenuRequested(QPoint)),
SLOT(showHeaderMenu(QPoint)));
connect(header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(sectionResized(int,int,int)));
this, SLOT(showHeaderMenu(QPoint)));
connect(header(), SIGNAL(sectionResized(int,int,int)),
this, SLOT(sectionResized(int,int,int)));
connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(vScrollBarActionTriggered(int)));
}
@ -645,7 +646,8 @@ void PacketList::initHeaderContextMenu()
}
}
// Redraw the packet list and detail
// Redraw the packet list and detail. Called from many places, including
// columnsChanged.
void PacketList::redrawVisiblePackets() {
if (!cap_file_) return;
@ -658,6 +660,7 @@ void PacketList::redrawVisiblePackets() {
prefs.num_cols = g_list_length(prefs.col_list);
col_cleanup(&cap_file_->cinfo);
build_column_format_array(&cap_file_->cinfo, prefs.num_cols, FALSE);
setColumnVisibility();
packet_list_model_->resetColumns();
if (row >= 0) {
@ -674,6 +677,7 @@ void PacketList::redrawVisiblePackets() {
// - Persist across file closing and opening.
// - Save to recent when we save our profile (including shutting down).
// Called via recentFilesRead.
void PacketList::applyRecentColumnWidths()
{
// Either we've just started up or a profile has changed. Read
@ -701,7 +705,6 @@ void PacketList::applyRecentColumnWidths()
setColumnWidth(i, col_width) ;
}
column_state_ = header()->saveState();
redrawVisiblePackets();
}
void PacketList::recolorPackets()
@ -777,12 +780,8 @@ void PacketList::writeRecent(FILE *rf) {
} else {
fprintf (rf, " %s,", col_format_to_string(col_fmt));
}
width = columnWidth(col);
width = recent_get_column_width (col);
xalign = recent_get_column_xalign (col);
if (width == 0) {
/* We have not initialized the packet list yet, use old values */
width = recent_get_column_width (col);
}
fprintf (rf, " %d", width);
if (xalign != COLUMN_XALIGN_DEFAULT) {
fprintf (rf, ":%c", xalign);
@ -1194,14 +1193,12 @@ void PacketList::columnVisibilityTriggered()
setColumnVisibility();
}
void PacketList::sectionResized(int, int, int)
void PacketList::sectionResized(int col, int, int new_width)
{
// For some reason the width of column 1 gets set to 32 when we open a file after
// closing a previous one. I (Gerald) am not sure if this is a bug in Qt or if it's
// our doing. Either way this catches that and fixes it.
if (isVisible()) {
column_state_ = header()->saveState();
redrawVisiblePackets();
// Column 1 gets an invalid value (32 on OS X) when we're not yet
// visible.
recent_set_column_width(col, new_width);
}
}

View File

@ -106,6 +106,7 @@ private:
void setColumnVisibility();
int sizeHintForColumn(int column) const;
void initHeaderContextMenu();
signals:
void packetDissectionChanged();
void packetSelectionChanged();
@ -135,7 +136,7 @@ private slots:
void showHeaderMenu(QPoint pos);
void headerMenuTriggered();
void columnVisibilityTriggered();
void sectionResized(int, int, int);
void sectionResized(int col, int, int new_width);
void vScrollBarActionTriggered(int);
};

View File

@ -359,8 +359,8 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name)
prefs_apply_all();
emit preferencesChanged();
emit recentFilesRead();
emit columnsChanged();
emit recentFilesRead();
emit filterExpressionsChanged();
// macros_post_update();