Qt: Fix preference bugs.

Make sure we set the "resolved" member of the column fmt_data struct.

Emitting WiresharkApplication::AppSignals from a modal dialog can cause
event loop problems on OS X. Queue them up in PreferencesDialog and emit
them after closing.

Change-Id: I2de77778a0448db3b87d402e431b8e5f325cbbda
Reviewed-on: https://code.wireshark.org/review/4274
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2014-09-23 16:39:52 -07:00
parent ffe30fb0d3
commit 8fc2327766
5 changed files with 20 additions and 14 deletions

View File

@ -2794,9 +2794,9 @@ parse_column_format(fmt_data *cfmt, const char *fmt)
gchar **cust_format_info;
char *p;
int col_fmt;
gchar *col_custom_field;
long col_custom_occurrence;
gboolean col_resolved;
gchar *col_custom_field = NULL;
long col_custom_occurrence = 0;
gboolean col_resolved = TRUE;
/*
* Is this a custom column?
@ -2815,22 +2815,15 @@ parse_column_format(fmt_data *cfmt, const char *fmt)
g_strfreev(cust_format_info);
return FALSE;
}
} else {
col_custom_occurrence = 0;
}
if (col_custom_field && cust_format_info[1] && cust_format_info[2]) {
col_resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE;
} else {
col_resolved = TRUE;
}
g_strfreev(cust_format_info);
} else {
col_fmt = get_column_format_from_str(fmt);
if (col_fmt == -1)
return FALSE;
col_custom_field = NULL;
col_custom_occurrence = 0;
col_resolved = TRUE;
}
cfmt->fmt = col_fmt;

View File

@ -84,9 +84,12 @@ void ColumnPreferencesFrame::unstash()
QTreeWidgetItemIterator it(ui->columnTreeWidget);
while (*it) {
fmt_data *cfmt = g_new0(fmt_data, 1);
cfmt->visible = (*it)->checkState(visible_col_) == Qt::Checked ? TRUE : FALSE;
cfmt->title = g_strdup((*it)->text(title_col_).toUtf8().constData());
cfmt->fmt = (*it)->data(type_col_, Qt::UserRole).value<int>();
cfmt->visible = (*it)->checkState(visible_col_) == Qt::Checked ? TRUE : FALSE;
cfmt->resolved = TRUE;
if (cfmt->fmt == COL_CUSTOM) {
bool ok;
int occurrence = (*it)->text(custom_occurrence_col_).toInt(&ok);

View File

@ -1673,6 +1673,12 @@ void MainWindow::on_actionEditPreferences_triggered()
PreferencesDialog pref_dialog;
pref_dialog.exec();
// Emitting PacketDissectionChanged directly from PreferencesDialog
// can cause problems. Queue them up and emit them here.
foreach (WiresharkApplication::AppSignal app_signal, pref_dialog.appSignals()) {
wsApp->emitAppSignal(app_signal);
}
}
// View Menu

View File

@ -23,7 +23,6 @@
#include "ui_preferences_dialog.h"
#include "module_preferences_scroll_area.h"
#include "wireshark_application.h"
#ifdef HAVE_LIBPCAP
#ifdef _WIN32
@ -788,6 +787,7 @@ void PreferencesDialog::on_buttonBox_accepted()
gboolean must_redissect = FALSE;
// XXX - We should validate preferences as the user changes them, not here.
// XXX - We're also too enthusiastic about setting must_redissect.
// if (!prefs_main_fetch_all(parent_w, &must_redissect))
// return; /* Errors in some preference setting - already reported */
prefs_modules_foreach_submodules(NULL, module_prefs_unstash, (gpointer) &must_redissect);
@ -813,15 +813,15 @@ void PreferencesDialog::on_buttonBox_accepted()
#endif
wsApp->setMonospaceFont(prefs.gui_qt_font_name);
wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged);
/* Now destroy the "Preferences" dialog. */
// window_destroy(GTK_WIDGET(parent_w));
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged);
app_signals_ << WiresharkApplication::PacketDissectionChanged;
}
app_signals_ << WiresharkApplication::PreferencesChanged;
}
void PreferencesDialog::on_buttonBox_helpRequested()

View File

@ -30,6 +30,8 @@
#include <epan/prefs.h>
#include "wireshark_application.h"
#include <QDialog>
#include <QTreeWidgetItem>
#include <QComboBox>
@ -48,6 +50,7 @@ class PreferencesDialog : public QDialog
public:
explicit PreferencesDialog(QWidget *parent = 0);
~PreferencesDialog();
const QList<WiresharkApplication::AppSignal> appSignals() const { return app_signals_; }
protected:
void showEvent(QShowEvent *evt);
@ -63,6 +66,7 @@ private:
QString saved_string_pref_;
QComboBox *cur_combo_box_;
int saved_combo_idx_;
QList<WiresharkApplication::AppSignal> app_signals_;
private slots:
void on_prefsTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);