forked from osmocom/wireshark
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:
parent
2793069020
commit
2156413bf9
|
@ -326,8 +326,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
connect(&capture_file_, SIGNAL(captureFileReadFinished()),
|
connect(&capture_file_, SIGNAL(captureFileReadFinished()),
|
||||||
wsApp, SLOT(updateTaps()));
|
wsApp, SLOT(updateTaps()));
|
||||||
|
|
||||||
connect(wsApp, SIGNAL(columnsChanged()),
|
connect(wsApp, SIGNAL(recentFilesRead()),
|
||||||
packet_list_, SLOT(applyRecentColumnWidths()));
|
packet_list_, SLOT(applyRecentColumnWidths()));
|
||||||
|
connect(wsApp, SIGNAL(columnsChanged()),
|
||||||
|
packet_list_, SLOT(redrawVisiblePackets()));
|
||||||
connect(wsApp, SIGNAL(recentFilesRead()),
|
connect(wsApp, SIGNAL(recentFilesRead()),
|
||||||
this, SLOT(applyRecentPaneGeometry()));
|
this, SLOT(applyRecentPaneGeometry()));
|
||||||
connect(wsApp, SIGNAL(packetDissectionChanged()),
|
connect(wsApp, SIGNAL(packetDissectionChanged()),
|
||||||
|
|
|
@ -2111,6 +2111,7 @@ void MainWindow::on_actionViewResizeColumns_triggered()
|
||||||
{
|
{
|
||||||
for (int col = 0; col < packet_list_->packetListModel()->columnCount(); col++) {
|
for (int col = 0; col < packet_list_->packetListModel()->columnCount(); col++) {
|
||||||
packet_list_->resizeColumnToContents(col);
|
packet_list_->resizeColumnToContents(col);
|
||||||
|
recent_set_column_width(col, packet_list_->columnWidth(col));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -417,8 +417,9 @@ PacketList::PacketList(QWidget *parent) :
|
||||||
|
|
||||||
header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(header(), SIGNAL(customContextMenuRequested(QPoint)),
|
connect(header(), SIGNAL(customContextMenuRequested(QPoint)),
|
||||||
SLOT(showHeaderMenu(QPoint)));
|
this, SLOT(showHeaderMenu(QPoint)));
|
||||||
connect(header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(sectionResized(int,int,int)));
|
connect(header(), SIGNAL(sectionResized(int,int,int)),
|
||||||
|
this, SLOT(sectionResized(int,int,int)));
|
||||||
|
|
||||||
connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(vScrollBarActionTriggered(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() {
|
void PacketList::redrawVisiblePackets() {
|
||||||
if (!cap_file_) return;
|
if (!cap_file_) return;
|
||||||
|
|
||||||
|
@ -658,6 +660,7 @@ void PacketList::redrawVisiblePackets() {
|
||||||
prefs.num_cols = g_list_length(prefs.col_list);
|
prefs.num_cols = g_list_length(prefs.col_list);
|
||||||
col_cleanup(&cap_file_->cinfo);
|
col_cleanup(&cap_file_->cinfo);
|
||||||
build_column_format_array(&cap_file_->cinfo, prefs.num_cols, FALSE);
|
build_column_format_array(&cap_file_->cinfo, prefs.num_cols, FALSE);
|
||||||
|
setColumnVisibility();
|
||||||
|
|
||||||
packet_list_model_->resetColumns();
|
packet_list_model_->resetColumns();
|
||||||
if (row >= 0) {
|
if (row >= 0) {
|
||||||
|
@ -674,6 +677,7 @@ void PacketList::redrawVisiblePackets() {
|
||||||
// - Persist across file closing and opening.
|
// - Persist across file closing and opening.
|
||||||
// - Save to recent when we save our profile (including shutting down).
|
// - Save to recent when we save our profile (including shutting down).
|
||||||
|
|
||||||
|
// Called via recentFilesRead.
|
||||||
void PacketList::applyRecentColumnWidths()
|
void PacketList::applyRecentColumnWidths()
|
||||||
{
|
{
|
||||||
// Either we've just started up or a profile has changed. Read
|
// Either we've just started up or a profile has changed. Read
|
||||||
|
@ -701,7 +705,6 @@ void PacketList::applyRecentColumnWidths()
|
||||||
setColumnWidth(i, col_width) ;
|
setColumnWidth(i, col_width) ;
|
||||||
}
|
}
|
||||||
column_state_ = header()->saveState();
|
column_state_ = header()->saveState();
|
||||||
redrawVisiblePackets();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketList::recolorPackets()
|
void PacketList::recolorPackets()
|
||||||
|
@ -777,12 +780,8 @@ void PacketList::writeRecent(FILE *rf) {
|
||||||
} else {
|
} else {
|
||||||
fprintf (rf, " %s,", col_format_to_string(col_fmt));
|
fprintf (rf, " %s,", col_format_to_string(col_fmt));
|
||||||
}
|
}
|
||||||
width = columnWidth(col);
|
width = recent_get_column_width (col);
|
||||||
xalign = recent_get_column_xalign (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);
|
fprintf (rf, " %d", width);
|
||||||
if (xalign != COLUMN_XALIGN_DEFAULT) {
|
if (xalign != COLUMN_XALIGN_DEFAULT) {
|
||||||
fprintf (rf, ":%c", xalign);
|
fprintf (rf, ":%c", xalign);
|
||||||
|
@ -1194,14 +1193,12 @@ void PacketList::columnVisibilityTriggered()
|
||||||
setColumnVisibility();
|
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()) {
|
if (isVisible()) {
|
||||||
column_state_ = header()->saveState();
|
// Column 1 gets an invalid value (32 on OS X) when we're not yet
|
||||||
redrawVisiblePackets();
|
// visible.
|
||||||
|
recent_set_column_width(col, new_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ private:
|
||||||
void setColumnVisibility();
|
void setColumnVisibility();
|
||||||
int sizeHintForColumn(int column) const;
|
int sizeHintForColumn(int column) const;
|
||||||
void initHeaderContextMenu();
|
void initHeaderContextMenu();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void packetDissectionChanged();
|
void packetDissectionChanged();
|
||||||
void packetSelectionChanged();
|
void packetSelectionChanged();
|
||||||
|
@ -135,7 +136,7 @@ private slots:
|
||||||
void showHeaderMenu(QPoint pos);
|
void showHeaderMenu(QPoint pos);
|
||||||
void headerMenuTriggered();
|
void headerMenuTriggered();
|
||||||
void columnVisibilityTriggered();
|
void columnVisibilityTriggered();
|
||||||
void sectionResized(int, int, int);
|
void sectionResized(int col, int, int new_width);
|
||||||
void vScrollBarActionTriggered(int);
|
void vScrollBarActionTriggered(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -359,8 +359,8 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name)
|
||||||
prefs_apply_all();
|
prefs_apply_all();
|
||||||
|
|
||||||
emit preferencesChanged();
|
emit preferencesChanged();
|
||||||
emit recentFilesRead();
|
|
||||||
emit columnsChanged();
|
emit columnsChanged();
|
||||||
|
emit recentFilesRead();
|
||||||
emit filterExpressionsChanged();
|
emit filterExpressionsChanged();
|
||||||
// macros_post_update();
|
// macros_post_update();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue