aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2023-02-24 23:53:31 -0500
committerJohn Thacker <johnthacker@gmail.com>2023-03-06 12:17:02 +0000
commit53914b044780c3ebac42f465d7f54df27933d22e (patch)
tree802aa3472f3736ce32b6ec934870645664f969d5 /epan
parentc682f53222a7c9e4a9a554c5ad809612387e5cc5 (diff)
colors: Improve handling of errors
Pop up a dialog about bad coloring rules when reading the file (e.g., when first starting Wireshark), rather than waiting until you try to edit them. Have that dialog have details of the problem with the filter instead of a generic message. The report_warning code will consolidate multiple warnings into one if more than one filter has an error, rather than have lots of pop-ups. Since the dialog (or console message, in the unlikely event that somehow the colorfilters are read in a CLI tool) is called from the color filters code, get rid of the separate non-specific pop-up in ColoringRulesDialog and the special preference for having a bogus filter. Now, if the user has a bogus filter in the current profile's colorfilter, they'll get a useful pop-up warning at startup, when that filter is disabled. For filters imported / copied from other profiles through the coloring rules dialog, they'll get the same useful pop-up. For trying to enable a disabled coloring rules with an error, or inserting a *new* coloring rule with invalid filter expression (despite the editor's Red background warning about an invalid expression), there's already both the hint at the bottom of the screen and the OK button becomes disabled. (Maybe the hint could be larger or bold or something when there's an error.) Fix #14906. Fix #15034
Diffstat (limited to 'epan')
-rw-r--r--epan/color_filters.c7
-rw-r--r--epan/prefs.h1
2 files changed, 2 insertions, 6 deletions
diff --git a/epan/color_filters.c b/epan/color_filters.c
index c9929fd8a9..809c70a35f 100644
--- a/epan/color_filters.c
+++ b/epan/color_filters.c
@@ -22,6 +22,7 @@
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
+#include <wsutil/report_message.h>
#include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
@@ -609,8 +610,6 @@ read_filters_file(const gchar *path, FILE *f, gpointer user_data, color_filter_a
name = (gchar *)g_malloc(name_len + 1);
filter_exp = (gchar *)g_malloc(filter_exp_len + 1);
- prefs.unknown_colorfilters = FALSE;
-
while (1) {
if (skip_end_of_line) {
@@ -704,10 +703,8 @@ read_filters_file(const gchar *path, FILE *f, gpointer user_data, color_filter_a
df_error_t *df_err = NULL;
if (!disabled && !dfilter_compile(filter_exp, &temp_dfilter, &df_err)) {
- ws_warning("Could not compile \"%s\" in colorfilters file \"%s\".\n%s",
- name, path, df_err->msg);
+ report_warning("Disabling color filter: Could not compile \"%s\" in colorfilters file \"%s\".\n%s", name, path, df_err->msg);
dfilter_error_free(df_err);
- prefs.unknown_colorfilters = TRUE;
/* skip_end_of_line = TRUE; */
disabled = TRUE;
diff --git a/epan/prefs.h b/epan/prefs.h
index 7a7b72348d..c771a25337 100644
--- a/epan/prefs.h
+++ b/epan/prefs.h
@@ -211,7 +211,6 @@ typedef struct _e_prefs {
gint gui_debounce_timer;
gchar *saved_at_version;
gboolean unknown_prefs; /* unknown or obsolete pref(s) */
- gboolean unknown_colorfilters; /* Warn when saving unknown or obsolete color filters. */
gboolean gui_qt_packet_list_separator;
gboolean gui_qt_packet_header_column_definition;
gboolean gui_qt_packet_list_hover_style; /* Enable/Disable mouse-over colorization */