summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-09-20 11:30:38 -0700
committerMichael Mann <mmann78@netscape.net>2016-10-03 17:47:39 +0000
commit1320ea4d57bf376a6a1923a7103d3321b4de8cc3 (patch)
tree2d3d46b240884b314cf758488bf219d3f3ef4c7e
parentd2a59db2bbf944da07710d31d4f86fe5a27490dd (diff)
downloadwireshark-1320ea4d57bf376a6a1923a7103d3321b4de8cc3.tar.gz
Be more forgiving about invalid Coloring Rules.
In ColoringRulesDialog: Only check a rule's display filter if that rule is enabled. This keeps us from disabling the OK button when we shouldn't. Adjust the "Your coloring rules file contains unknown rules" dialog text and buttons for accuracy. In color_filters.c: Don't try to compile disabled filters in color_filters_apply. Don't warn about disabled and invalid filters in read_filters_file. Bug: 12814 Change-Id: I7143bf8e7a6162d296f1e93769344b69763195c8 Reviewed-on: https://code.wireshark.org/review/17823 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/color_filters.c10
-rw-r--r--epan/prefs.h2
-rw-r--r--ui/qt/coloring_rules_dialog.cpp12
3 files changed, 17 insertions, 7 deletions
diff --git a/epan/color_filters.c b/epan/color_filters.c
index b45c3a96e0..d0d37ef5fe 100644
--- a/epan/color_filters.c
+++ b/epan/color_filters.c
@@ -386,6 +386,10 @@ color_filter_compile_cb(gpointer filter_arg, gpointer err)
gchar *local_err_msg = NULL;
g_assert(colorf->c_colorfilter == NULL);
+
+ /* If the filter is disabled it doesn't matter if it compiles or not. */
+ if (colorf->disabled) return;
+
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &local_err_msg)) {
*err_msg = g_strdup_printf("Could not compile color filter name: \"%s\" text: \"%s\".\n%s",
colorf->filter_name, colorf->filter_text, local_err_msg);
@@ -404,6 +408,10 @@ color_filter_validate_cb(gpointer filter_arg, gpointer err)
gchar *local_err_msg;
g_assert(colorf->c_colorfilter == NULL);
+
+ /* If the filter is disabled it doesn't matter if it compiles or not. */
+ if (colorf->disabled) return;
+
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &local_err_msg)) {
*err_msg = g_strdup_printf("Removing color filter name: \"%s\" text: \"%s\".\n%s",
colorf->filter_name, colorf->filter_text, local_err_msg);
@@ -621,7 +629,7 @@ read_filters_file(const gchar *path, FILE *f, gpointer user_data, color_filter_a
dfilter_t *temp_dfilter;
gchar *local_err_msg = NULL;
- if (!dfilter_compile(filter_exp, &temp_dfilter, &local_err_msg)) {
+ if (!disabled && !dfilter_compile(filter_exp, &temp_dfilter, &local_err_msg)) {
ws_g_warning("Could not compile \"%s\" in colorfilters file \"%s\".\n%s",
name, path, local_err_msg);
g_free(local_err_msg);
diff --git a/epan/prefs.h b/epan/prefs.h
index 81243b3b69..bbec99c70d 100644
--- a/epan/prefs.h
+++ b/epan/prefs.h
@@ -221,7 +221,7 @@ typedef struct _e_prefs {
gint gui_update_interval;
gchar *saved_at_version;
gboolean unknown_prefs; /* unknown or obsolete pref(s) */
- gboolean unknown_colorfilters; /* unknown or obsolete color filter(s) */
+ gboolean unknown_colorfilters; /* Warn when saving unknown or obsolete color filters. */
gboolean gui_qt_packet_list_separator;
gboolean gui_packet_editor; /* Enable Packet Editor */
elide_mode_e gui_packet_list_elide_mode;
diff --git a/ui/qt/coloring_rules_dialog.cpp b/ui/qt/coloring_rules_dialog.cpp
index 671a9c075d..fa6242f8e5 100644
--- a/ui/qt/coloring_rules_dialog.cpp
+++ b/ui/qt/coloring_rules_dialog.cpp
@@ -175,8 +175,9 @@ void ColoringRulesDialog::updateWidgets()
error_text = tr("the \"@\" symbol will be ignored.");
}
+ // Check the rule's display filter syntax only if it's checked.
QString display_filter = item->text(filter_col_);
- if (!display_filter.isEmpty()) {
+ if (!display_filter.isEmpty() && item->checkState(name_col_) == Qt::Checked) {
dfilter_t *dfilter;
bool status;
gchar *err_msg;
@@ -306,6 +307,7 @@ void ColoringRulesDialog::on_deleteToolButton_clicked()
foreach (QTreeWidgetItem *ti, selected) {
delete ti;
}
+ updateWidgets();
}
void ColoringRulesDialog::on_copyToolButton_clicked()
@@ -360,9 +362,8 @@ void ColoringRulesDialog::on_buttonBox_accepted()
QMessageBox mb;
mb.setText(tr("Your coloring rules file contains unknown rules"));
mb.setInformativeText(tr("Wireshark doesn't recognize one or more of your coloring rules. "
- "Saving will disable them."));
- mb.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
- mb.setDefaultButton(QMessageBox::Save);
+ "They have been disabled."));
+ mb.setStandardButtons(QMessageBox::Ok);
int result = mb.exec();
if (result != QMessageBox::Save) return;
@@ -383,7 +384,6 @@ void ColoringRulesDialog::on_buttonBox_helpRequested()
wsApp->helpTopicAction(HELP_COLORING_RULES_DIALOG);
}
-
//
// ColoringRulesTreeDelegate
// Delegate for editing coloring rule names and filters.
@@ -409,6 +409,8 @@ QWidget *ColoringRulesTreeDelegate::createEditor(QWidget *parent, const QStyleOp
case filter_col_:
{
DisplayFilterEdit *dfe = new DisplayFilterEdit(parent);
+ // It's possible to have an invalid filter and an enabled OK button at this point.
+ // We might want to add a local slot for checking the filter status.
connect(dfe, SIGNAL(textChanged(QString)), dfe, SLOT(checkDisplayFilter(QString)));
dfe->setText(ti->text(filter_col_));
w = (QWidget*) dfe;