Remove some GTK+-only code.
[metze/wireshark/wip.git] / epan / prefs.c
index 860ef4d3140f377bef944abf3c6e558cb2521b3b..c2d1dfc9ddd4891dcc034889e6aa596db1f08473 100644 (file)
@@ -5,23 +5,13 @@
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include "config.h"
 
  */
 
 #include "config.h"
 
+#include "ws_diag_control.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <epan/address.h>
 #include <epan/addr_resolv.h>
 #include <epan/oids.h>
 #include <epan/address.h>
 #include <epan/addr_resolv.h>
 #include <epan/oids.h>
-#ifdef HAVE_GEOIP
-#include <epan/geoip_db.h>
-#endif
+#include <epan/maxmind_db.h>
 #include <epan/packet.h>
 #include <epan/prefs.h>
 #include <epan/proto.h>
 #include <epan/strutil.h>
 #include <epan/column.h>
 #include <epan/packet.h>
 #include <epan/prefs.h>
 #include <epan/proto.h>
 #include <epan/strutil.h>
 #include <epan/column.h>
+#include <epan/decode_as.h>
 #include "print.h"
 #include <wsutil/file_util.h>
 #include "print.h"
 #include <wsutil/file_util.h>
+#include <wsutil/ws_printf.h> /* ws_g_warning */
+#include <wsutil/report_message.h>
 
 #include <epan/prefs-int.h>
 #include <epan/uat-int.h>
 
 #include <epan/prefs-int.h>
 #include <epan/uat-int.h>
@@ -64,7 +55,12 @@ static void pre_init_prefs(void);
 static gboolean prefs_is_column_visible(const gchar *cols_hidden, fmt_data *cfmt);
 static gboolean parse_column_format(fmt_data *cfmt, const char *fmt);
 static void try_convert_to_custom_column(gpointer *el_data);
 static gboolean prefs_is_column_visible(const gchar *cols_hidden, fmt_data *cfmt);
 static gboolean parse_column_format(fmt_data *cfmt, const char *fmt);
 static void try_convert_to_custom_column(gpointer *el_data);
+static guint prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
+                          gpointer user_data, gboolean skip_obsolete);
 
 
+#define IS_PREF_OBSOLETE(p) ((p) & PREF_OBSOLETE)
+#define SET_PREF_OBSOLETE(p) ((p) |= PREF_OBSOLETE)
+#define RESET_PREF_OBSOLETE(p) ((p) &= ~PREF_OBSOLETE)
 
 #define PF_NAME         "preferences"
 #define OLD_GPF_NAME    "wireshark.conf" /* old name for global preferences file */
 
 #define PF_NAME         "preferences"
 #define OLD_GPF_NAME    "wireshark.conf" /* old name for global preferences file */
@@ -72,6 +68,7 @@ static void try_convert_to_custom_column(gpointer *el_data);
 static gboolean prefs_initialized = FALSE;
 static gchar *gpf_path = NULL;
 static gchar *cols_hidden_list = NULL;
 static gboolean prefs_initialized = FALSE;
 static gchar *gpf_path = NULL;
 static gchar *cols_hidden_list = NULL;
+static gboolean gui_theme_is_dark = FALSE;
 
 /*
  * XXX - variables to allow us to attempt to interpret the first
 
 /*
  * XXX - variables to allow us to attempt to interpret the first
@@ -100,12 +97,6 @@ static const enum_val_t gui_ptree_expander_style[] = {
     {NULL, NULL, -1}
 };
 
     {NULL, NULL, -1}
 };
 
-static const enum_val_t gui_hex_dump_highlight_style[] = {
-    {"BOLD", "BOLD", 0},
-    {"INVERSE", "INVERSE", 1},
-    {NULL, NULL, -1}
-};
-
 static const enum_val_t gui_console_open_type[] = {
     {"NEVER", "NEVER", console_open_never},
     {"AUTOMATIC", "AUTOMATIC", console_open_auto},
 static const enum_val_t gui_console_open_type[] = {
     {"NEVER", "NEVER", console_open_never},
     {"AUTOMATIC", "AUTOMATIC", console_open_auto},
@@ -127,8 +118,6 @@ static const enum_val_t gui_fileopen_style[] = {
     {NULL, NULL, -1}
 };
 
     {NULL, NULL, -1}
 };
 
-/* GTK knows of two ways representing "both", vertical and horizontal aligned.
- * as this may not work on other guis, we use only "both" in general here */
 static const enum_val_t gui_toolbar_style[] = {
     {"ICONS", "ICONS", 0},
     {"TEXT", "TEXT", 1},
 static const enum_val_t gui_toolbar_style[] = {
     {"ICONS", "ICONS", 0},
     {"TEXT", "TEXT", 1},
@@ -199,6 +188,89 @@ static const enum_val_t gui_packet_list_elide_mode[] = {
     {NULL, NULL, -1}
 };
 
     {NULL, NULL, -1}
 };
 
+/** Struct to hold preference data */
+struct preference {
+    const char *name;                /**< name of preference */
+    const char *title;               /**< title to use in GUI */
+    const char *description;         /**< human-readable description of preference */
+    int ordinal;                     /**< ordinal number of this preference */
+    int type;                        /**< type of that preference */
+    unsigned int effect_flags;       /**< Flags of types effected by preference (PREF_TYPE_DISSECTION, PREF_EFFECT_CAPTURE, etc).
+                                          Flags must be non-zero to ensure saving to disk */
+    gui_type_t gui;                  /**< type of the GUI (QT, GTK or both) the preference is registered for */
+    union {                          /* The Qt preference code assumes that these will all be pointers (and unique) */
+        guint *uint;
+        gboolean *boolp;
+        gint *enump;
+        char **string;
+        range_t **range;
+        struct epan_uat* uat;
+        color_t *colorp;
+        GList** list;
+    } varp;                          /**< pointer to variable storing the value */
+    union {
+        guint uint;
+        gboolean boolval;
+        gint enumval;
+        char *string;
+        range_t *range;
+        color_t color;
+        GList* list;
+    } stashed_val;                     /**< original value, when editing from the GUI */
+    union {
+        guint uint;
+        gboolean boolval;
+        gint enumval;
+        char *string;
+        range_t *range;
+        color_t color;
+        GList* list;
+    } default_val;                   /**< the default value of the preference */
+    union {
+      guint base;                    /**< input/output base, for PREF_UINT */
+      guint32 max_value;             /**< maximum value of a range */
+      struct {
+        const enum_val_t *enumvals;  /**< list of name & values */
+        gboolean radio_buttons;      /**< TRUE if it should be shown as
+                                          radio buttons rather than as an
+                                          option menu or combo box in
+                                          the preferences tab */
+      } enum_info;                   /**< for PREF_ENUM */
+    } info;                          /**< display/text file information */
+    struct pref_custom_cbs custom_cbs;   /**< for PREF_CUSTOM */
+    void    *control;                /**< handle for GUI control for this preference. GTK+ only? */
+};
+
+const char* prefs_get_description(pref_t *pref)
+{
+    return pref->description;
+}
+
+const char* prefs_get_title(pref_t *pref)
+{
+    return pref->title;
+}
+
+int prefs_get_type(pref_t *pref)
+{
+    return pref->type;
+}
+
+gui_type_t prefs_get_gui_type(pref_t *pref)
+{
+    return pref->gui;
+}
+
+const char* prefs_get_name(pref_t *pref)
+{
+    return pref->name;
+}
+
+guint32 prefs_get_max_value(pref_t *pref)
+{
+    return pref->info.max_value;
+}
+
 /*
  * List of all modules with preference settings.
  */
 /*
  * List of all modules with preference settings.
  */
@@ -225,7 +297,9 @@ prefs_init(void)
 static void
 free_string_like_preference(pref_t *pref)
 {
 static void
 free_string_like_preference(pref_t *pref)
 {
+DIAG_OFF(cast-qual)
     g_free((char *)*pref->varp.string);
     g_free((char *)*pref->varp.string);
+DIAG_ON(cast-qual)
     *pref->varp.string = NULL;
     g_free(pref->default_val.string);
     pref->default_val.string = NULL;
     *pref->varp.string = NULL;
     g_free(pref->default_val.string);
     pref->default_val.string = NULL;
@@ -235,28 +309,31 @@ static void
 free_pref(gpointer data, gpointer user_data _U_)
 {
     pref_t *pref = (pref_t *)data;
 free_pref(gpointer data, gpointer user_data _U_)
 {
     pref_t *pref = (pref_t *)data;
+    int type = pref->type;
 
 
-    switch (pref->type) {
-    case PREF_OBSOLETE:
+    /* we reset the PREF_OBSOLETE bit in order to allow the original preference to be freed */
+    RESET_PREF_OBSOLETE(type);
+
+    switch (type) {
     case PREF_BOOL:
     case PREF_ENUM:
     case PREF_UINT:
     case PREF_BOOL:
     case PREF_ENUM:
     case PREF_UINT:
+    case PREF_DECODE_AS_UINT:
     case PREF_STATIC_TEXT:
     case PREF_UAT:
     case PREF_COLOR:
         break;
     case PREF_STRING:
     case PREF_STATIC_TEXT:
     case PREF_UAT:
     case PREF_COLOR:
         break;
     case PREF_STRING:
-    case PREF_FILENAME:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
     case PREF_DIRNAME:
     case PREF_DIRNAME:
-        g_free((char *)*pref->varp.string);
-        *pref->varp.string = NULL;
-        g_free(pref->default_val.string);
-        pref->default_val.string = NULL;
+        free_string_like_preference(pref);
         break;
     case PREF_RANGE:
         break;
     case PREF_RANGE:
-        g_free(*pref->varp.range);
+    case PREF_DECODE_AS_RANGE:
+        wmem_free(wmem_epan_scope(), *pref->varp.range);
         *pref->varp.range = NULL;
         *pref->varp.range = NULL;
-        g_free(pref->default_val.range);
+        wmem_free(wmem_epan_scope(), pref->default_val.range);
         pref->default_val.range = NULL;
         break;
     case PREF_CUSTOM:
         pref->default_val.range = NULL;
         break;
     case PREF_CUSTOM:
@@ -279,7 +356,7 @@ free_module_prefs(module_t *module, gpointer data _U_)
     module->prefs = NULL;
     module->numprefs = 0;
     if (module->submodules) {
     module->prefs = NULL;
     module->numprefs = 0;
     if (module->submodules) {
-        prefs_modules_foreach_submodules(module, free_module_prefs, NULL);
+        prefs_module_list_foreach(module->submodules, free_module_prefs, NULL, FALSE);
     }
     /*  We don't free the actual module: its submodules pointer points to
         a wmem_tree and the module itself is stored in a wmem_tree
     }
     /*  We don't free the actual module: its submodules pointer points to
         a wmem_tree and the module itself is stored in a wmem_tree
@@ -295,7 +372,22 @@ prefs_cleanup(void)
     /*  This isn't strictly necessary since we're exiting anyway, but let's
      *  do what clean up we can.
      */
     /*  This isn't strictly necessary since we're exiting anyway, but let's
      *  do what clean up we can.
      */
-    prefs_modules_foreach(free_module_prefs, NULL);
+    prefs_module_list_foreach(prefs_modules, free_module_prefs, NULL, FALSE);
+
+    /* Clean the uats */
+    uat_cleanup();
+
+    /* Shut down mmdbresolve */
+    maxmind_db_pref_cleanup();
+
+    g_free(prefs.saved_at_version);
+    g_free(gpf_path);
+    gpf_path = NULL;
+}
+
+void prefs_set_gui_theme_is_dark(gboolean is_dark)
+{
+    gui_theme_is_dark = is_dark;
 }
 
 /*
 }
 
 /*
@@ -305,7 +397,7 @@ prefs_cleanup(void)
  * the title used in the tab for it in a preferences dialog box, and a
  * routine to call back when we apply the preferences.
  */
  * the title used in the tab for it in a preferences dialog box, and a
  * routine to call back when we apply the preferences.
  */
-module_t *
+static module_t *
 prefs_register_module(module_t *parent, const char *name, const char *title,
                       const char *description, void (*apply_cb)(void),
                       const gboolean use_gui)
 prefs_register_module(module_t *parent, const char *name, const char *title,
                       const char *description, void (*apply_cb)(void),
                       const gboolean use_gui)
@@ -341,7 +433,7 @@ prefs_deregister_module(module_t *parent, const char *name, const char *title)
  * at the top level and the title used in the tab for it in a preferences
  * dialog box.
  */
  * at the top level and the title used in the tab for it in a preferences
  * dialog box.
  */
-module_t *
+static module_t *
 prefs_register_subtree(module_t *parent, const char *title, const char *description,
                        void (*apply_cb)(void))
 {
 prefs_register_subtree(module_t *parent, const char *title, const char *description,
                        void (*apply_cb)(void))
 {
@@ -384,9 +476,11 @@ prefs_register_module_or_subtree(module_t *parent, const char *name,
     module->parent = parent;
     module->submodules = NULL;    /* no submodules, to start */
     module->numprefs = 0;
     module->parent = parent;
     module->submodules = NULL;    /* no submodules, to start */
     module->numprefs = 0;
-    module->prefs_changed = FALSE;
+    module->prefs_changed_flags = 0;
     module->obsolete = FALSE;
     module->use_gui = use_gui;
     module->obsolete = FALSE;
     module->use_gui = use_gui;
+    /* A module's preferences affects dissection unless otherwise told */
+    module->effect_flags = PREF_EFFECT_DISSECTION;
 
     /*
      * Do we have a module name?
 
     /*
      * Do we have a module name?
@@ -403,9 +497,11 @@ prefs_register_module_or_subtree(module_t *parent, const char *name,
          * on the command line, and shouldn't require quoting,
          * shifting, etc.
          */
          * on the command line, and shouldn't require quoting,
          * shifting, etc.
          */
-        for (p = name; (c = *p) != '\0'; p++)
-            g_assert(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
-                 c == '-' || c == '.');
+        for (p = name; (c = *p) != '\0'; p++) {
+            if (!(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
+                  c == '-' || c == '.'))
+                g_error("Preference module \"%s\" contains invalid characters", name);
+        }
 
         /*
          * Make sure there's not already a module with that
 
         /*
          * Make sure there's not already a module with that
@@ -478,6 +574,8 @@ prefs_register_protocol(int id, void (*apply_cb)(void))
         prefs_register_modules();
     }
     protocol = find_protocol_by_id(id);
         prefs_register_modules();
     }
     protocol = find_protocol_by_id(id);
+    if (protocol == NULL)
+        g_error("Protocol preferences being registered with an invalid protocol ID");
     return prefs_register_module(protocols_module,
                                  proto_get_protocol_filter_name(id),
                                  proto_get_protocol_short_name(protocol),
     return prefs_register_module(protocols_module,
                                  proto_get_protocol_filter_name(id),
                                  proto_get_protocol_short_name(protocol),
@@ -488,6 +586,8 @@ void
 prefs_deregister_protocol (int id)
 {
     protocol_t *protocol = find_protocol_by_id(id);
 prefs_deregister_protocol (int id)
 {
     protocol_t *protocol = find_protocol_by_id(id);
+    if (protocol == NULL)
+        g_error("Protocol preferences being de-registered with an invalid protocol ID");
     prefs_deregister_module (protocols_module,
                              proto_get_protocol_filter_name(id),
                              proto_get_protocol_short_name(protocol));
     prefs_deregister_module (protocols_module,
                              proto_get_protocol_filter_name(id),
                              proto_get_protocol_short_name(protocol));
@@ -533,7 +633,7 @@ prefs_register_protocol_subtree(const char *subtree, int id, void (*apply_cb)(vo
                  * being the name (if it's later registered explicitly
                  * with a description, that will override it).
                  */
                  * being the name (if it's later registered explicitly
                  * with a description, that will override it).
                  */
-                ptr = wmem_strdup(wmem_epan_scope(), ptr),
+                ptr = wmem_strdup(wmem_epan_scope(), ptr);
                 new_module = prefs_register_subtree(subtree_module, ptr, ptr, NULL);
             }
 
                 new_module = prefs_register_subtree(subtree_module, ptr, ptr, NULL);
             }
 
@@ -546,6 +646,8 @@ prefs_register_protocol_subtree(const char *subtree, int id, void (*apply_cb)(vo
     }
 
     protocol = find_protocol_by_id(id);
     }
 
     protocol = find_protocol_by_id(id);
+    if (protocol == NULL)
+        g_error("Protocol subtree being registered with an invalid protocol ID");
     return prefs_register_module(subtree_module,
                                  proto_get_protocol_filter_name(id),
                                  proto_get_protocol_short_name(protocol),
     return prefs_register_module(subtree_module,
                                  proto_get_protocol_filter_name(id),
                                  proto_get_protocol_short_name(protocol),
@@ -575,6 +677,8 @@ prefs_register_protocol_obsolete(int id)
         prefs_register_modules();
     }
     protocol = find_protocol_by_id(id);
         prefs_register_modules();
     }
     protocol = find_protocol_by_id(id);
+    if (protocol == NULL)
+        g_error("Protocol being registered with an invalid protocol ID");
     module = prefs_register_module(protocols_module,
                                    proto_get_protocol_filter_name(id),
                                    proto_get_protocol_short_name(protocol),
     module = prefs_register_module(protocols_module,
                                    proto_get_protocol_filter_name(id),
                                    proto_get_protocol_short_name(protocol),
@@ -615,6 +719,38 @@ prefs_register_stat(const char *name, const char *title,
                                  apply_cb, TRUE);
 }
 
                                  apply_cb, TRUE);
 }
 
+/*
+ * Register that a codec has preferences.
+ *
+ * "name" is a name for the codec to use on the command line with "-o"
+ * and in preference files.
+ *
+ * "title" is a short human-readable name for the codec.
+ *
+ * "description" is a longer human-readable description of the codec.
+ */
+module_t *codecs_module = NULL;
+
+module_t *
+prefs_register_codec(const char *name, const char *title,
+                     const char *description, void (*apply_cb)(void))
+{
+    /*
+     * Have we yet created the "Codecs" subtree?
+     */
+    if (codecs_module == NULL) {
+        /*
+         * No.  Register Codecs subtree as well as any preferences
+         * for non-dissector modules.
+         */
+        pre_init_prefs();
+        prefs_register_modules();
+    }
+
+    return prefs_register_module(codecs_module, name, title, description,
+                                 apply_cb, TRUE);
+}
+
 module_t *
 prefs_find_module(const char *name)
 {
 module_t *
 prefs_find_module(const char *name)
 {
@@ -634,7 +770,7 @@ find_subtree(module_t *parent, const char *name)
  * non-zero value, we stop and return that value, otherwise we
  * return 0.
  *
  * non-zero value, we stop and return that value, otherwise we
  * return 0.
  *
- * Ignores "obsolete" modules; their sole purpose is to allow old
+ * Normally "obsolete" modules are ignored; their sole purpose is to allow old
  * preferences for dissectors that no longer have preferences to be
  * silently ignored in preference files.  Does not ignore subtrees,
  * as this can be used when walking the display tree of modules.
  * preferences for dissectors that no longer have preferences to be
  * silently ignored in preference files.  Does not ignore subtrees,
  * as this can be used when walking the display tree of modules.
@@ -644,6 +780,7 @@ typedef struct {
     module_cb callback;
     gpointer user_data;
     guint ret;
     module_cb callback;
     gpointer user_data;
     guint ret;
+    gboolean skip_obsolete;
 } call_foreach_t;
 
 static gboolean
 } call_foreach_t;
 
 static gboolean
@@ -652,7 +789,7 @@ call_foreach_cb(const void *key _U_, void *value, void *data)
     module_t *module = (module_t*)value;
     call_foreach_t *call_data = (call_foreach_t*)data;
 
     module_t *module = (module_t*)value;
     call_foreach_t *call_data = (call_foreach_t*)data;
 
-    if (!module->obsolete)
+    if (!call_data->skip_obsolete || !module->obsolete)
         call_data->ret = (*call_data->callback)(module, call_data->user_data);
 
     return (call_data->ret != 0);
         call_data->ret = (*call_data->callback)(module, call_data->user_data);
 
     return (call_data->ret != 0);
@@ -660,7 +797,7 @@ call_foreach_cb(const void *key _U_, void *value, void *data)
 
 static guint
 prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
 
 static guint
 prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
-                          gpointer user_data)
+                          gpointer user_data, gboolean skip_obsolete)
 {
     call_foreach_t call_data;
 
 {
     call_foreach_t call_data;
 
@@ -670,6 +807,7 @@ prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
     call_data.callback = callback;
     call_data.user_data = user_data;
     call_data.ret = 0;
     call_data.callback = callback;
     call_data.user_data = user_data;
     call_data.ret = 0;
+    call_data.skip_obsolete = skip_obsolete;
     wmem_tree_foreach(module_list, call_foreach_cb, &call_data);
     return call_data.ret;
 }
     wmem_tree_foreach(module_list, call_foreach_cb, &call_data);
     return call_data.ret;
 }
@@ -702,7 +840,7 @@ prefs_module_has_submodules(module_t *module)
 guint
 prefs_modules_foreach(module_cb callback, gpointer user_data)
 {
 guint
 prefs_modules_foreach(module_cb callback, gpointer user_data)
 {
-    return prefs_module_list_foreach(prefs_modules, callback, user_data);
+    return prefs_module_list_foreach(prefs_modules, callback, user_data, TRUE);
 }
 
 /*
 }
 
 /*
@@ -719,7 +857,7 @@ guint
 prefs_modules_foreach_submodules(module_t *module, module_cb callback,
                                  gpointer user_data)
 {
 prefs_modules_foreach_submodules(module_t *module, module_cb callback,
                                  gpointer user_data)
 {
-    return prefs_module_list_foreach((module)?module->submodules:prefs_top_level_modules, callback, user_data);
+    return prefs_module_list_foreach((module)?module->submodules:prefs_top_level_modules, callback, user_data, TRUE);
 }
 
 static gboolean
 }
 
 static gboolean
@@ -729,11 +867,13 @@ call_apply_cb(const void *key _U_, void *value, void *data _U_)
 
     if (module->obsolete)
         return FALSE;
 
     if (module->obsolete)
         return FALSE;
-    if (module->prefs_changed) {
+    if (module->prefs_changed_flags) {
         if (module->apply_cb != NULL)
             (*module->apply_cb)();
         if (module->apply_cb != NULL)
             (*module->apply_cb)();
-        module->prefs_changed = FALSE;
+        module->prefs_changed_flags = 0;
     }
     }
+    if (module->submodules)
+        wmem_tree_foreach(module->submodules, call_apply_cb, NULL);
     return FALSE;
 }
 
     return FALSE;
 }
 
@@ -758,7 +898,7 @@ prefs_apply_all(void)
 void
 prefs_apply(module_t *module)
 {
 void
 prefs_apply(module_t *module)
 {
-    if (module && module->prefs_changed)
+    if (module && module->prefs_changed_flags)
         call_apply_cb(NULL, module, NULL);
 }
 
         call_apply_cb(NULL, module, NULL);
 }
 
@@ -771,16 +911,20 @@ prefs_apply(module_t *module)
  */
 static pref_t *
 register_preference(module_t *module, const char *name, const char *title,
  */
 static pref_t *
 register_preference(module_t *module, const char *name, const char *title,
-                    const char *description, pref_type_t type)
+                    const char *description, int type)
 {
     pref_t *preference;
     const gchar *p;
 {
     pref_t *preference;
     const gchar *p;
+    const char *name_prefix = (module->name != NULL) ? module->name : module->parent->name;
 
     preference = g_new(pref_t,1);
     preference->name = name;
     preference->title = title;
     preference->description = description;
     preference->type = type;
 
     preference = g_new(pref_t,1);
     preference->name = name;
     preference->title = title;
     preference->description = description;
     preference->type = type;
+    /* Default to module's preference effects */
+    preference->effect_flags = module->effect_flags;
+
     preference->gui = GUI_ALL;  /* default */
     if (title != NULL)
         preference->ordinal = module->numprefs;
     preference->gui = GUI_ALL;  /* default */
     if (title != NULL)
         preference->ordinal = module->numprefs;
@@ -799,7 +943,7 @@ register_preference(module_t *module, const char *name, const char *title,
      */
     for (p = name; *p != '\0'; p++)
         if (!(g_ascii_islower(*p) || g_ascii_isdigit(*p) || *p == '_' || *p == '.'))
      */
     for (p = name; *p != '\0'; p++)
         if (!(g_ascii_islower(*p) || g_ascii_isdigit(*p) || *p == '_' || *p == '.'))
-            g_error("Preference %s.%s contains invalid characters", module->name, name);
+            g_error("Preference \"%s.%s\" contains invalid characters", module->name, name);
 
     /*
      * Make sure there's not already a preference with that
 
     /*
      * Make sure there's not already a preference with that
@@ -810,7 +954,7 @@ register_preference(module_t *module, const char *name, const char *title,
     if (prefs_find_preference(module, name) != NULL)
         g_error("Preference %s has already been registered", name);
 
     if (prefs_find_preference(module, name) != NULL)
         g_error("Preference %s has already been registered", name);
 
-    if ((type != PREF_OBSOLETE) &&
+    if ((!IS_PREF_OBSOLETE(type)) &&
         /* Don't compare if it's a subtree */
         (module->name != NULL)) {
         /*
         /* Don't compare if it's a subtree */
         (module->name != NULL)) {
         /*
@@ -822,9 +966,32 @@ register_preference(module_t *module, const char *name, const char *title,
             g_error("Preference %s begins with the module name", name);
     }
 
             g_error("Preference %s begins with the module name", name);
     }
 
+    /* The title shows up in the preferences dialog. Make sure it's UI-friendly. */
+    if (preference->title) {
+        const char *cur_char;
+        if (preference->type != PREF_STATIC_TEXT && g_utf8_strlen(preference->title, -1) > 80) { // Arbitrary.
+            g_error("Title for preference %s.%s is too long: %s", name_prefix, preference->name, preference->title);
+        }
+
+        if (!g_utf8_validate(preference->title, -1, NULL)) {
+            g_error("Title for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name);
+        }
+
+        for (cur_char = preference->title; *cur_char; cur_char = g_utf8_next_char(cur_char)) {
+            if (!g_unichar_isprint(g_utf8_get_char(cur_char))) {
+                g_error("Title for preference %s.%s isn't printable UTF-8.", name_prefix, preference->name);
+            }
+        }
+    }
+
+    if (preference->description) {
+        if (!g_utf8_validate(preference->description, -1, NULL)) {
+            g_error("Description for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name);
+        }
+    }
+
     /*
     /*
-     * There isn't already one with that name, so add the
-     * preference.
+     * We passed all of our checks. Add the preference.
      */
     module->prefs = g_list_append(module->prefs, preference);
     if (title != NULL)
      */
     module->prefs = g_list_append(module->prefs, preference);
     if (title != NULL)
@@ -840,6 +1007,7 @@ register_preference(module_t *module, const char *name, const char *title,
 typedef struct {
     GList *list_entry;
     const char *name;
 typedef struct {
     GList *list_entry;
     const char *name;
+    module_t *submodule;
 } find_pref_arg_t;
 
 static gint
 } find_pref_arg_t;
 
 static gint
@@ -868,11 +1036,15 @@ module_find_pref_cb(const void *key _U_, void *value, void *data)
         return FALSE;
 
     arg->list_entry = list_entry;
         return FALSE;
 
     arg->list_entry = list_entry;
+    arg->submodule = module;
     return TRUE;
 }
 
     return TRUE;
 }
 
-struct preference *
-prefs_find_preference(module_t *module, const char *name)
+/* Tries to find a preference, setting containing_module to the (sub)module
+ * holding this preference. */
+static struct preference *
+prefs_find_preference_with_submodule(module_t *module, const char *name,
+        module_t **containing_module)
 {
     find_pref_arg_t arg;
     GList *list_entry;
 {
     find_pref_arg_t arg;
     GList *list_entry;
@@ -882,6 +1054,7 @@ prefs_find_preference(module_t *module, const char *name)
 
     list_entry = g_list_find_custom(module->prefs, name,
         preference_match);
 
     list_entry = g_list_find_custom(module->prefs, name,
         preference_match);
+    arg.submodule = NULL;
 
     if (list_entry == NULL)
     {
 
     if (list_entry == NULL)
     {
@@ -898,9 +1071,18 @@ prefs_find_preference(module_t *module, const char *name)
     if (list_entry == NULL)
         return NULL;    /* no such preference */
 
     if (list_entry == NULL)
         return NULL;    /* no such preference */
 
+    if (containing_module)
+        *containing_module = arg.submodule ? arg.submodule : module;
+
     return (struct preference *) list_entry->data;
 }
 
     return (struct preference *) list_entry->data;
 }
 
+struct preference *
+prefs_find_preference(module_t *module, const char *name)
+{
+    return prefs_find_preference_with_submodule(module, name, NULL);
+}
+
 /*
  * Returns TRUE if the given protocol has registered preferences
  */
 /*
  * Returns TRUE if the given protocol has registered preferences
  */
@@ -982,9 +1164,85 @@ prefs_register_bool_preference(module_t *module, const char *name,
     preference->default_val.boolval = *var;
 }
 
     preference->default_val.boolval = *var;
 }
 
+unsigned int prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source)
+{
+    unsigned int changed = 0;
+
+    switch (source)
+    {
+    case pref_default:
+        if (pref->default_val.boolval != value) {
+            pref->default_val.boolval = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    case pref_stashed:
+        if (pref->stashed_val.boolval != value) {
+            pref->stashed_val.boolval = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    case pref_current:
+        if (*pref->varp.boolp != value) {
+            *pref->varp.boolp = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return changed;
+}
+
+void prefs_invert_bool_value(pref_t *pref, pref_source_t source)
+{
+    switch (source)
+    {
+    case pref_default:
+        pref->default_val.boolval = !pref->default_val.boolval;
+        break;
+    case pref_stashed:
+        pref->stashed_val.boolval = !pref->stashed_val.boolval;
+        break;
+    case pref_current:
+        *pref->varp.boolp = !(*pref->varp.boolp);
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+}
+
+gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source)
+{
+    switch (source)
+    {
+    case pref_default:
+        return pref->default_val.boolval;
+        break;
+    case pref_stashed:
+        return pref->stashed_val.boolval;
+        break;
+    case pref_current:
+        return *pref->varp.boolp;
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return FALSE;
+}
+
 /*
  * Register a preference with an enumerated value.
  */
 /*
  * Register a preference with an enumerated value.
  */
+/*
+ * XXX Should we get rid of the radio_buttons parameter and make that
+ * behavior automatic depending on the number of items?
+ */
 void
 prefs_register_enum_preference(module_t *module, const char *name,
                                const char *title, const char *description,
 void
 prefs_register_enum_preference(module_t *module, const char *name,
                                const char *title, const char *description,
@@ -1001,16 +1259,80 @@ prefs_register_enum_preference(module_t *module, const char *name,
     preference->info.enum_info.radio_buttons = radio_buttons;
 }
 
     preference->info.enum_info.radio_buttons = radio_buttons;
 }
 
-static pref_t*
+unsigned int prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source)
+{
+    unsigned int changed = 0;
+
+    switch (source)
+    {
+    case pref_default:
+        if (pref->default_val.enumval != value) {
+            pref->default_val.enumval = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    case pref_stashed:
+        if (pref->stashed_val.enumval != value) {
+            pref->stashed_val.enumval = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    case pref_current:
+        if (*pref->varp.enump != value) {
+            *pref->varp.enump = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return changed;
+}
+
+gint prefs_get_enum_value(pref_t *pref, pref_source_t source)
+{
+    switch (source)
+    {
+    case pref_default:
+        return pref->default_val.enumval;
+        break;
+    case pref_stashed:
+        return pref->stashed_val.enumval;
+        break;
+    case pref_current:
+        return *pref->varp.enump;
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return 0;
+}
+
+const enum_val_t* prefs_get_enumvals(pref_t *pref)
+{
+    return pref->info.enum_info.enumvals;
+}
+
+gboolean prefs_get_enum_radiobuttons(pref_t *pref)
+{
+    return pref->info.enum_info.radio_buttons;
+}
+
+static void
 register_string_like_preference(module_t *module, const char *name,
                                 const char *title, const char *description,
 register_string_like_preference(module_t *module, const char *name,
                                 const char *title, const char *description,
-                                const char **var, pref_type_t type)
+                                char **var, int type,
+                                struct pref_custom_cbs* custom_cbs,
+                                gboolean free_tmp)
 {
 {
-    pref_t *preference;
-    char *varcopy;
+    pref_t *pref;
+    gchar *tmp;
 
 
-    preference = register_preference(module, name, title, description,
-                                     type);
+    pref = register_preference(module, name, title, description, type);
 
     /*
      * String preference values should be non-null (as you can't
 
     /*
      * String preference values should be non-null (as you can't
@@ -1021,35 +1343,102 @@ register_string_like_preference(module_t *module, const char *name,
      * If the value is a null pointer, make it a copy of a null
      * string, otherwise make it a copy of the value.
      */
      * If the value is a null pointer, make it a copy of a null
      * string, otherwise make it a copy of the value.
      */
+    tmp = *var;
     if (*var == NULL) {
         *var = g_strdup("");
     if (*var == NULL) {
         *var = g_strdup("");
-        varcopy = g_strdup("");
     } else {
         *var = g_strdup(*var);
     } else {
         *var = g_strdup(*var);
-        varcopy = g_strdup(*var);
     }
     }
-    preference->varp.string = var;
-    preference->default_val.string = varcopy;
-    preference->stashed_val.string = NULL;
+    if (free_tmp) {
+        g_free(tmp);
+    }
+    pref->varp.string = var;
+    pref->default_val.string = g_strdup(*var);
+    pref->stashed_val.string = NULL;
+    if (type == PREF_CUSTOM) {
+        g_assert(custom_cbs);
+        pref->custom_cbs = *custom_cbs;
+    }
+}
 
 
-    return preference;
+/*
+ * Assign to a string preference.
+ */
+static void
+pref_set_string_like_pref_value(pref_t *pref, const gchar *value)
+{
+DIAG_OFF(cast-qual)
+    g_free((void *)*pref->varp.string);
+DIAG_ON(cast-qual)
+    *pref->varp.string = g_strdup(value);
 }
 
 /*
  * For use by UI code that sets preferences.
  */
 }
 
 /*
  * For use by UI code that sets preferences.
  */
-void
-prefs_set_string_like_value(pref_t *pref, const gchar *value, gboolean *changed)
+unsigned int
+prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source)
 {
 {
-    if (*pref->varp.string) {
-        if (strcmp(*pref->varp.string, value) != 0) {
-            *changed = TRUE;
-            g_free((void *)*pref->varp.string);
-            *pref->varp.string = g_strdup(value);
+    unsigned int changed = 0;
+
+    switch (source)
+    {
+    case pref_default:
+        if (*pref->default_val.string) {
+            if (strcmp(pref->default_val.string, value) != 0) {
+                changed = prefs_get_effect_flags(pref);
+                g_free(pref->default_val.string);
+                pref->default_val.string = g_strdup(value);
+            }
+        } else if (value) {
+            pref->default_val.string = g_strdup(value);
+        }
+        break;
+    case pref_stashed:
+        if (pref->stashed_val.string) {
+            if (strcmp(pref->stashed_val.string, value) != 0) {
+                changed = prefs_get_effect_flags(pref);
+                g_free(pref->stashed_val.string);
+                pref->stashed_val.string = g_strdup(value);
+            }
+        } else if (value) {
+            pref->stashed_val.string = g_strdup(value);
+        }
+        break;
+    case pref_current:
+        if (*pref->varp.string) {
+            if (strcmp(*pref->varp.string, value) != 0) {
+                changed = prefs_get_effect_flags(pref);
+                pref_set_string_like_pref_value(pref, value);
+            }
+        } else if (value) {
+            pref_set_string_like_pref_value(pref, value);
         }
         }
-    } else if (value) {
-        *pref->varp.string = g_strdup(value);
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return changed;
+}
+
+char* prefs_get_string_value(pref_t *pref, pref_source_t source)
+{
+    switch (source)
+    {
+    case pref_default:
+        return pref->default_val.string;
+    case pref_stashed:
+        return pref->stashed_val.string;
+    case pref_current:
+        return *pref->varp.string;
+    default:
+        g_assert_not_reached();
+        break;
     }
     }
+
+    return NULL;
 }
 
 /*
 }
 
 /*
@@ -1058,9 +1447,7 @@ prefs_set_string_like_value(pref_t *pref, const gchar *value, gboolean *changed)
 static void
 reset_string_like_preference(pref_t *pref)
 {
 static void
 reset_string_like_preference(pref_t *pref)
 {
-DIAG_OFF(cast-qual)
-    g_free((void *)*pref->varp.string);
-DIAG_ON(cast-qual)
+    g_free(*pref->varp.string);
     *pref->varp.string = g_strdup(pref->default_val.string);
 }
 
     *pref->varp.string = g_strdup(pref->default_val.string);
 }
 
@@ -1072,39 +1459,24 @@ prefs_register_string_preference(module_t *module, const char *name,
                                  const char *title, const char *description,
                                  const char **var)
 {
                                  const char *title, const char *description,
                                  const char **var)
 {
-    register_string_like_preference(module, name, title, description, var,
-                                    PREF_STRING);
-}
-
-/*
- * Register a "custom" preference with a character-string value.
- * XXX - This should be temporary until we can find a better way
- * to do "custom" preferences
- */
-static void
-prefs_register_string_custom_preference(module_t *module, const char *name,
-                                 const char *title, const char *description,
-                                 struct pref_custom_cbs* custom_cbs, const char **var)
-{
-    pref_t *preference;
-
-    preference = register_string_like_preference(module, name, title, description, var,
-                                    PREF_CUSTOM);
-
-    preference->custom_cbs = *custom_cbs;
+DIAG_OFF(cast-qual)
+    register_string_like_preference(module, name, title, description,
+                                    (char **)var, PREF_STRING, NULL, FALSE);
+DIAG_ON(cast-qual)
 }
 
 }
 
-
 /*
  * Register a preference with a file name (string) value.
  */
 void
 prefs_register_filename_preference(module_t *module, const char *name,
                                    const char *title, const char *description,
 /*
  * Register a preference with a file name (string) value.
  */
 void
 prefs_register_filename_preference(module_t *module, const char *name,
                                    const char *title, const char *description,
-                                   const char **var)
+                                   const char **var, gboolean for_writing)
 {
 {
-    register_string_like_preference(module, name, title, description, var,
-                                    PREF_FILENAME);
+DIAG_OFF(cast-qual)
+    register_string_like_preference(module, name, title, description, (char **)var,
+                                    for_writing ? PREF_SAVE_FILENAME : PREF_OPEN_FILENAME, NULL, FALSE);
+DIAG_ON(cast-qual)
 }
 
 /*
 }
 
 /*
@@ -1115,25 +1487,23 @@ prefs_register_directory_preference(module_t *module, const char *name,
                                    const char *title, const char *description,
                                    const char **var)
 {
                                    const char *title, const char *description,
                                    const char **var)
 {
-    register_string_like_preference(module, name, title, description, var,
-                                    PREF_DIRNAME);
+DIAG_OFF(cast-qual)
+    register_string_like_preference(module, name, title, description,
+                                    (char **)var, PREF_DIRNAME, NULL, FALSE);
+DIAG_ON(cast-qual)
 }
 
 }
 
-/*
- * Register a preference with a ranged value.
- */
-void
-prefs_register_range_preference(module_t *module, const char *name,
+/* Refactoring to handle both PREF_RANGE and PREF_DECODE_AS_RANGE */
+static void
+prefs_register_range_preference_common(module_t *module, const char *name,
                                 const char *title, const char *description,
                                 const char *title, const char *description,
-                                range_t **var, guint32 max_value)
+                                range_t **var, guint32 max_value, int type)
 {
     pref_t *preference;
 
 {
     pref_t *preference;
 
-    preference = register_preference(module, name, title, description,
-                                     PREF_RANGE);
+    preference = register_preference(module, name, title, description, type);
     preference->info.max_value = max_value;
 
     preference->info.max_value = max_value;
 
-
     /*
      * Range preference values should be non-null (as you can't
      * keep them null after using the preferences GUI, you can at best
     /*
      * Range preference values should be non-null (as you can't
      * keep them null after using the preferences GUI, you can at best
@@ -1143,29 +1513,41 @@ prefs_register_range_preference(module_t *module, const char *name,
      * If the value is a null pointer, make it an empty range.
      */
     if (*var == NULL)
      * If the value is a null pointer, make it an empty range.
      */
     if (*var == NULL)
-        *var = range_empty();
+        *var = range_empty(wmem_epan_scope());
     preference->varp.range = var;
     preference->varp.range = var;
-    preference->default_val.range = range_copy(*var);
+    preference->default_val.range = range_copy(wmem_epan_scope(), *var);
     preference->stashed_val.range = NULL;
 }
 
     preference->stashed_val.range = NULL;
 }
 
-static gboolean
+/*
+ * Register a preference with a ranged value.
+ */
+void
+prefs_register_range_preference(module_t *module, const char *name,
+                                const char *title, const char *description,
+                                range_t **var, guint32 max_value)
+{
+    prefs_register_range_preference_common(module, name, title,
+                description, var, max_value, PREF_RANGE);
+}
+
+gboolean
 prefs_set_range_value_work(pref_t *pref, const gchar *value,
 prefs_set_range_value_work(pref_t *pref, const gchar *value,
-                           gboolean return_range_errors, gboolean *changed)
+                           gboolean return_range_errors, unsigned int *changed_flags)
 {
     range_t *newrange;
 
 {
     range_t *newrange;
 
-    if (range_convert_str_work(&newrange, value, pref->info.max_value,
+    if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
                                return_range_errors) != CVT_NO_ERROR) {
         return FALSE;        /* number was bad */
     }
 
     if (!ranges_are_equal(*pref->varp.range, newrange)) {
                                return_range_errors) != CVT_NO_ERROR) {
         return FALSE;        /* number was bad */
     }
 
     if (!ranges_are_equal(*pref->varp.range, newrange)) {
-        *changed = TRUE;
-        g_free(*pref->varp.range);
+        *changed_flags |= prefs_get_effect_flags(pref);
+        wmem_free(wmem_epan_scope(), *pref->varp.range);
         *pref->varp.range = newrange;
     } else {
         *pref->varp.range = newrange;
     } else {
-        g_free(newrange);
+        wmem_free(wmem_epan_scope(), newrange);
     }
     return TRUE;
 }
     }
     return TRUE;
 }
@@ -1173,18 +1555,104 @@ prefs_set_range_value_work(pref_t *pref, const gchar *value,
 /*
  * For use by UI code that sets preferences.
  */
 /*
  * For use by UI code that sets preferences.
  */
-gboolean
-prefs_set_range_value(pref_t *pref, const gchar *value, gboolean *changed)
+unsigned int
+prefs_set_stashed_range_value(pref_t *pref, const gchar *value)
 {
 {
-    return prefs_set_range_value_work(pref, value, TRUE, changed);
+    range_t *newrange;
+
+    if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
+                               TRUE) != CVT_NO_ERROR) {
+        return 0;        /* number was bad */
+    }
+
+    if (!ranges_are_equal(pref->stashed_val.range, newrange)) {
+        wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+        pref->stashed_val.range = newrange;
+    } else {
+        wmem_free(wmem_epan_scope(), newrange);
+    }
+    return prefs_get_effect_flags(pref);
+
 }
 
 }
 
-/*
- * Register a static text 'preference'.  It can be used to add explanatory
- * text inline with other preferences in the GUI.
- * Note: Static preferences are not saved to the preferences file.
- */
-void
+gboolean prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source)
+{
+    gboolean changed = FALSE;
+
+    switch (source)
+    {
+    case pref_default:
+        if (!ranges_are_equal(pref->default_val.range, value)) {
+            wmem_free(wmem_epan_scope(), pref->default_val.range);
+            pref->default_val.range = range_copy(wmem_epan_scope(), value);
+            changed = TRUE;
+        }
+        break;
+    case pref_stashed:
+        if (!ranges_are_equal(pref->stashed_val.range, value)) {
+            wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+            pref->stashed_val.range = range_copy(wmem_epan_scope(), value);
+            changed = TRUE;
+        }
+        break;
+    case pref_current:
+        if (!ranges_are_equal(*pref->varp.range, value)) {
+            wmem_free(wmem_epan_scope(), *pref->varp.range);
+            *pref->varp.range = range_copy(wmem_epan_scope(), value);
+            changed = TRUE;
+        }
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return changed;
+}
+
+range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source)
+{
+    switch (source)
+    {
+    case pref_default:
+        return pref->default_val.range;
+    case pref_stashed:
+        return pref->stashed_val.range;
+        break;
+    case pref_current:
+        return *pref->varp.range;
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return NULL;
+}
+
+range_t* prefs_get_range_value(const char *module_name, const char* pref_name)
+{
+    return prefs_get_range_value_real(prefs_find_preference(prefs_find_module(module_name), pref_name), pref_current);
+}
+
+void
+prefs_range_add_value(pref_t *pref, guint32 val)
+{
+    range_add_value(wmem_epan_scope(), pref->varp.range, val);
+}
+
+void
+prefs_range_remove_value(pref_t *pref, guint32 val)
+{
+    range_remove_value(wmem_epan_scope(), pref->varp.range, val);
+}
+
+/*
+ * Register a static text 'preference'.  It can be used to add explanatory
+ * text inline with other preferences in the GUI.
+ * Note: Static preferences are not saved to the preferences file.
+ */
+void
 prefs_register_static_text_preference(module_t *module, const char *name,
                                       const char *title,
                                       const char *description)
 prefs_register_static_text_preference(module_t *module, const char *name,
                                       const char *title,
                                       const char *description)
@@ -1207,106 +1675,536 @@ prefs_register_uat_preference(module_t *module, const char *name,
     preference->varp.uat = uat;
 }
 
     preference->varp.uat = uat;
 }
 
-/*
- * Register a uat 'preference' for QT only. It adds a button that opens the uat's window in the
- * preferences tab of the module.
- */
-extern void
-prefs_register_uat_preference_qt(module_t *module, const char *name,
-                              const char *title, const char *description,
-                              uat_t* uat)
-{
+/*
+ * Register a uat 'preference' for QT only. It adds a button that opens the uat's window in the
+ * preferences tab of the module.
+ */
+extern void
+prefs_register_uat_preference_qt(module_t *module, const char *name,
+                              const char *title, const char *description,
+                              uat_t* uat)
+{
+
+    pref_t* preference = register_preference(module, name, title, description, PREF_UAT);
+
+    preference->varp.uat = uat;
+
+    preference->gui = GUI_QT;
+}
+
+struct epan_uat* prefs_get_uat_value(pref_t *pref)
+{
+    return pref->varp.uat;
+}
+
+/*
+ * Register a color preference.
+ */
+void
+prefs_register_color_preference(module_t *module, const char *name,
+                                const char *title, const char *description,
+                                color_t *color)
+{
+    pref_t* preference = register_preference(module, name, title, description, PREF_COLOR);
+
+    preference->varp.colorp = color;
+    preference->default_val.color = *color;
+}
+
+gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source)
+{
+    gboolean changed = FALSE;
+
+    switch (source)
+    {
+    case pref_default:
+        if ((pref->default_val.color.red != value.red) &&
+            (pref->default_val.color.green != value.green) &&
+            (pref->default_val.color.blue != value.blue)) {
+            changed = TRUE;
+            pref->default_val.color = value;
+        }
+        break;
+    case pref_stashed:
+        if ((pref->stashed_val.color.red != value.red) &&
+            (pref->stashed_val.color.green != value.green) &&
+            (pref->stashed_val.color.blue != value.blue)) {
+            changed = TRUE;
+            pref->stashed_val.color = value;
+        }
+        break;
+    case pref_current:
+        if ((pref->varp.colorp->red != value.red) &&
+            (pref->varp.colorp->green != value.green) &&
+            (pref->varp.colorp->blue != value.blue)) {
+            changed = TRUE;
+            *pref->varp.colorp = value;
+        }
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return changed;
+}
+
+color_t* prefs_get_color_value(pref_t *pref, pref_source_t source)
+{
+    switch (source)
+    {
+    case pref_default:
+        return &pref->default_val.color;
+    case pref_stashed:
+        return &pref->stashed_val.color;
+        break;
+    case pref_current:
+        return pref->varp.colorp;
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return NULL;
+}
+
+/*
+ * Register a "custom" preference with a list.
+ * XXX - This should be temporary until we can find a better way
+ * to do "custom" preferences
+ */
+typedef void (*pref_custom_list_init_cb) (pref_t* pref, GList** value);
+
+static void
+prefs_register_list_custom_preference(module_t *module, const char *name,
+                                      const char *title, const char *description,
+                                      struct pref_custom_cbs* custom_cbs,
+                                      pref_custom_list_init_cb init_cb,
+                                      GList** list)
+{
+    pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
+
+    preference->custom_cbs = *custom_cbs;
+    init_cb(preference, list);
+}
+
+/*
+ * Register a custom preference.
+ */
+void
+prefs_register_custom_preference(module_t *module, const char *name,
+                                 const char *title, const char *description,
+                                 struct pref_custom_cbs* custom_cbs,
+                                 void **custom_data _U_)
+{
+    pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
+
+    preference->custom_cbs = *custom_cbs;
+    /* XXX - wait until we can handle void** pointers
+    preference->custom_cbs.init_cb(preference, custom_data);
+    */
+}
+
+/*
+ * Register a (internal) "Decode As" preference with a ranged value.
+ */
+void prefs_register_decode_as_range_preference(module_t *module, const char *name,
+    const char *title, const char *description, range_t **var,
+    guint32 max_value)
+{
+    prefs_register_range_preference_common(module, name, title,
+                description, var, max_value, PREF_DECODE_AS_RANGE);
+}
+
+/*
+ * Register a (internal) "Decode As" preference with an unsigned integral value
+ * for a dissector table.
+ */
+void prefs_register_decode_as_preference(module_t *module, const char *name,
+    const char *title, const char *description, guint *var)
+{
+    pref_t *preference;
+
+    preference = register_preference(module, name, title, description,
+                                     PREF_DECODE_AS_UINT);
+    preference->varp.uint = var;
+    preference->default_val.uint = *var;
+    /* XXX - Presume base 10 for now */
+    preference->info.base = 10;
+}
+
+gboolean prefs_add_decode_as_value(pref_t *pref, guint value, gboolean replace)
+{
+    switch(pref->type)
+    {
+    case PREF_DECODE_AS_UINT:
+        /* This doesn't support multiple values for a dissector in Decode As because the
+            preference only supports a single value. This leads to a "last port for
+            dissector in Decode As wins" */
+        *pref->varp.uint = value;
+        break;
+    case PREF_DECODE_AS_RANGE:
+        if (replace)
+        {
+            /* If range has single value, replace it */
+            if (((*pref->varp.range)->nranges == 1) &&
+                ((*pref->varp.range)->ranges[0].low == (*pref->varp.range)->ranges[0].high)) {
+                wmem_free(wmem_epan_scope(), *pref->varp.range);
+                *pref->varp.range = range_empty(wmem_epan_scope());
+            }
+        }
+
+        prefs_range_add_value(pref, value);
+        break;
+    default:
+        /* XXX - Worth asserting over? */
+        break;
+    }
+
+    return TRUE;
+}
+
+gboolean prefs_remove_decode_as_value(pref_t *pref, guint value, gboolean set_default)
+{
+    switch(pref->type)
+    {
+    case PREF_DECODE_AS_UINT:
+        if (set_default) {
+            *pref->varp.uint = pref->default_val.uint;
+        } else {
+            *pref->varp.uint = 0;
+        }
+        break;
+    case PREF_DECODE_AS_RANGE:
+        prefs_range_remove_value(pref, value);
+        break;
+    default:
+        break;
+    }
+
+    return TRUE;
+}
+
+/*
+ * Register a preference that used to be supported but no longer is.
+ */
+void
+prefs_register_obsolete_preference(module_t *module, const char *name)
+{
+    register_preference(module, name, NULL, NULL, PREF_OBSOLETE);
+}
+
+/*
+ * Check to see if a preference is obsolete.
+ */
+extern gboolean
+prefs_get_preference_obsolete(pref_t *pref)
+{
+    if (pref)
+        return (IS_PREF_OBSOLETE(pref->type) ? TRUE : FALSE);
+
+    return TRUE;
+}
+
+/*
+ * Make a preference obsolete.
+ */
+extern prefs_set_pref_e
+prefs_set_preference_obsolete(pref_t *pref)
+{
+    if (pref) {
+        SET_PREF_OBSOLETE(pref->type);
+        return PREFS_SET_OK;
+    }
+    return PREFS_SET_NO_SUCH_PREF;
+}
+
+guint
+pref_stash(pref_t *pref, gpointer unused _U_)
+{
+    switch (pref->type) {
+
+    case PREF_DECODE_AS_UINT:
+        pref->stashed_val.uint = *pref->varp.uint;
+        break;
+
+    case PREF_UINT:
+        pref->stashed_val.uint = *pref->varp.uint;
+        break;
+
+    case PREF_BOOL:
+        pref->stashed_val.boolval = *pref->varp.boolp;
+        break;
+
+    case PREF_ENUM:
+        pref->stashed_val.enumval = *pref->varp.enump;
+        break;
+
+    case PREF_STRING:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
+    case PREF_DIRNAME:
+        g_free(pref->stashed_val.string);
+        pref->stashed_val.string = g_strdup(*pref->varp.string);
+        break;
+
+    case PREF_DECODE_AS_RANGE:
+    case PREF_RANGE:
+        wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+        pref->stashed_val.range = range_copy(wmem_epan_scope(), *pref->varp.range);
+        break;
+
+    case PREF_COLOR:
+        pref->stashed_val.color = *pref->varp.colorp;
+        break;
+
+    case PREF_STATIC_TEXT:
+    case PREF_UAT:
+    case PREF_CUSTOM:
+        break;
+
+    case PREF_OBSOLETE:
+        g_assert_not_reached();
+        break;
+    }
+    return 0;
+}
+
+guint
+pref_unstash(pref_t *pref, gpointer unstash_data_p)
+{
+    pref_unstash_data_t *unstash_data = (pref_unstash_data_t *)unstash_data_p;
+    dissector_table_t sub_dissectors = NULL;
+    dissector_handle_t handle = NULL;
+
+    /* Revert the preference to its saved value. */
+    switch (pref->type) {
+
+    case PREF_DECODE_AS_UINT:
+        if (*pref->varp.uint != pref->stashed_val.uint) {
+            unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+            if (unstash_data->handle_decode_as) {
+                if (*pref->varp.uint != pref->default_val.uint) {
+                    dissector_reset_uint(pref->name, *pref->varp.uint);
+                }
+            }
+
+            *pref->varp.uint = pref->stashed_val.uint;
+
+            if (unstash_data->handle_decode_as) {
+                sub_dissectors = find_dissector_table(pref->name);
+                if (sub_dissectors != NULL) {
+                    handle = dissector_table_get_dissector_handle(sub_dissectors, unstash_data->module->title);
+                    if (handle != NULL) {
+                        dissector_change_uint(pref->name, *pref->varp.uint, handle);
+                    }
+                }
+            }
+        }
+        break;
+
+    case PREF_UINT:
+        if (*pref->varp.uint != pref->stashed_val.uint) {
+            unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+            *pref->varp.uint = pref->stashed_val.uint;
+        }
+        break;
+
+    case PREF_BOOL:
+        if (*pref->varp.boolp != pref->stashed_val.boolval) {
+            unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+            *pref->varp.boolp = pref->stashed_val.boolval;
+        }
+        break;
+
+    case PREF_ENUM:
+        if (*pref->varp.enump != pref->stashed_val.enumval) {
+            unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+            *pref->varp.enump = pref->stashed_val.enumval;
+        }
+        break;
+
+    case PREF_STRING:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
+    case PREF_DIRNAME:
+        if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0) {
+            unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+            g_free(*pref->varp.string);
+            *pref->varp.string = g_strdup(pref->stashed_val.string);
+        }
+        break;
+
+    case PREF_DECODE_AS_RANGE:
+        if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) {
+            guint32 i, j;
+            unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+            if (unstash_data->handle_decode_as) {
+                sub_dissectors = find_dissector_table(pref->name);
+                if (sub_dissectors != NULL) {
+                    handle = dissector_table_get_dissector_handle(sub_dissectors, unstash_data->module->title);
+                    if (handle != NULL) {
+                        /* Delete all of the old values from the dissector table */
+                        for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+                            for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+                                dissector_delete_uint(pref->name, j, handle);
+                                decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+                            }
+
+                            dissector_delete_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+                            decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+                        }
+                    }
+                }
+            }
+
+            wmem_free(wmem_epan_scope(), *pref->varp.range);
+            *pref->varp.range = range_copy(wmem_epan_scope(), pref->stashed_val.range);
+
+            if (unstash_data->handle_decode_as) {
+                if ((sub_dissectors != NULL) && (handle != NULL)) {
+
+                    /* Add new values to the dissector table */
+                    for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+
+                        for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+                            dissector_change_uint(pref->name, j, handle);
+                            decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+                        }
+
+                        dissector_change_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+                        decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+                    }
+                }
+            }
+        }
+        break;
+
+    case PREF_RANGE:
+        if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) {
+            unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+            wmem_free(wmem_epan_scope(), *pref->varp.range);
+            *pref->varp.range = range_copy(wmem_epan_scope(), pref->stashed_val.range);
+        }
+    break;
+
+    case PREF_COLOR:
+        if ((pref->varp.colorp->blue != pref->stashed_val.color.blue) ||
+            (pref->varp.colorp->red != pref->stashed_val.color.red) ||
+            (pref->varp.colorp->green != pref->stashed_val.color.green)) {
+            unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+            *pref->varp.colorp = pref->stashed_val.color;
+        }
+        break;
+
+    case PREF_STATIC_TEXT:
+    case PREF_UAT:
+    case PREF_CUSTOM:
+        break;
+
+    case PREF_OBSOLETE:
+        g_assert_not_reached();
+        break;
+    }
+    return 0;
+}
+
+void
+reset_stashed_pref(pref_t *pref) {
+    switch (pref->type) {
 
 
-    pref_t* preference = register_preference(module, name, title, description, PREF_UAT);
+    case PREF_DECODE_AS_UINT:
+        pref->stashed_val.uint = pref->default_val.uint;
+        break;
 
 
-    preference->varp.uat = uat;
+    case PREF_UINT:
+        pref->stashed_val.uint = pref->default_val.uint;
+        break;
 
 
-    preference->gui = GUI_QT;
-}
+    case PREF_BOOL:
+        pref->stashed_val.boolval = pref->default_val.boolval;
+        break;
 
 
-/*
- * Register a color preference.
- */
-void
-prefs_register_color_preference(module_t *module, const char *name,
-                                const char *title, const char *description,
-                                color_t *color)
-{
-    pref_t* preference = register_preference(module, name, title, description, PREF_COLOR);
+    case PREF_ENUM:
+        pref->stashed_val.enumval = pref->default_val.enumval;
+        break;
 
 
-    preference->varp.colorp = color;
-    preference->default_val.color = *color;
-}
+    case PREF_STRING:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
+    case PREF_DIRNAME:
+        g_free(pref->stashed_val.string);
+        pref->stashed_val.string = g_strdup(pref->default_val.string);
+        break;
 
 
-/*
- * Register a "custom" preference with a list.
- * XXX - This should be temporary until we can find a better way
- * to do "custom" preferences
- */
-typedef void (*pref_custom_list_init_cb) (pref_t* pref, GList** value);
+    case PREF_DECODE_AS_RANGE:
+    case PREF_RANGE:
+        wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+        pref->stashed_val.range = range_copy(wmem_epan_scope(), pref->default_val.range);
+        break;
 
 
-static void
-prefs_register_list_custom_preference(module_t *module, const char *name,
-                                      const char *title, const char *description,
-                                      struct pref_custom_cbs* custom_cbs,
-                                      pref_custom_list_init_cb init_cb,
-                                      GList** list)
-{
-    pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
+    case PREF_COLOR:
+        memcpy(&pref->stashed_val.color, &pref->default_val.color, sizeof(color_t));
+        break;
 
 
-    preference->custom_cbs = *custom_cbs;
-    init_cb(preference, list);
+    case PREF_STATIC_TEXT:
+    case PREF_UAT:
+    case PREF_CUSTOM:
+        break;
+
+    case PREF_OBSOLETE:
+        g_assert_not_reached();
+        break;
+    }
 }
 
 }
 
-/*
- * Register a custom preference.
- */
-void
-prefs_register_custom_preference(module_t *module, const char *name,
-                                 const char *title, const char *description,
-                                 struct pref_custom_cbs* custom_cbs,
-                                 void **custom_data _U_)
+guint
+pref_clean_stash(pref_t *pref, gpointer unused _U_)
 {
 {
-    pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
+    switch (pref->type) {
 
 
-    preference->custom_cbs = *custom_cbs;
-    /* XXX - wait until we can handle void** pointers
-    preference->custom_cbs.init_cb(preference, custom_data);
-    */
-}
+    case PREF_UINT:
+    case PREF_DECODE_AS_UINT:
+        break;
 
 
-/*
- * Register a preference that used to be supported but no longer is.
- */
-void
-prefs_register_obsolete_preference(module_t *module, const char *name)
-{
-    register_preference(module, name, NULL, NULL, PREF_OBSOLETE);
-}
+    case PREF_BOOL:
+        break;
 
 
-/*
- * Check to see if a preference is obsolete.
- */
-extern gboolean
-prefs_get_preference_obsolete(pref_t *pref)
-{
-    if (pref)
-        return pref->type == PREF_OBSOLETE ? TRUE : FALSE;
+    case PREF_ENUM:
+        break;
 
 
-    return TRUE;
-}
+    case PREF_STRING:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
+    case PREF_DIRNAME:
+        if (pref->stashed_val.string != NULL) {
+            g_free(pref->stashed_val.string);
+            pref->stashed_val.string = NULL;
+        }
+        break;
 
 
-/*
- * Make a preference obsolete.
- */
-extern prefs_set_pref_e
-prefs_set_preference_obsolete(pref_t *pref)
-{
-    if (pref) {
-        pref->type = PREF_OBSOLETE;
-        return PREFS_SET_OK;
+    case PREF_DECODE_AS_RANGE:
+    case PREF_RANGE:
+        if (pref->stashed_val.range != NULL) {
+            wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+            pref->stashed_val.range = NULL;
+        }
+        break;
+
+    case PREF_STATIC_TEXT:
+    case PREF_UAT:
+    case PREF_COLOR:
+    case PREF_CUSTOM:
+        break;
+
+    case PREF_OBSOLETE:
+        g_assert_not_reached();
+        break;
     }
     }
-    return PREFS_SET_NO_SUCH_PREF;
+    return 0;
 }
 
 #if 0
 }
 
 #if 0
@@ -1336,7 +2234,7 @@ prefs_pref_foreach(module_t *module, pref_cb callback, gpointer user_data)
 
     for (elem = g_list_first(module->prefs); elem != NULL; elem = g_list_next(elem)) {
         pref = (pref_t *)elem->data;
 
     for (elem = g_list_first(module->prefs); elem != NULL; elem = g_list_next(elem)) {
         pref = (pref_t *)elem->data;
-        if (pref->type == PREF_OBSOLETE) {
+        if (IS_PREF_OBSOLETE(pref->type)) {
             /*
              * This preference is no longer supported; it's
              * not a real preference, so we don't call the
             /*
              * This preference is no longer supported; it's
              * not a real preference, so we don't call the
@@ -1388,12 +2286,6 @@ stats_callback(void)
     if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000)
         prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
 
     if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000)
         prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
 
-#ifdef HAVE_LIBPORTAUDIO
-    /* Test for a sane max channels entry */
-    if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
-        prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
-#endif
-
     /* burst resolution can't be less than 1 (ms) */
     if (prefs.st_burst_resolution < 1) {
         prefs.st_burst_resolution = 1;
     /* burst resolution can't be less than 1 (ms) */
     if (prefs.st_burst_resolution < 1) {
         prefs.st_burst_resolution = 1;
@@ -1451,14 +2343,14 @@ console_log_level_reset_cb(pref_t* pref)
 }
 
 static prefs_set_pref_e
 }
 
 static prefs_set_pref_e
-console_log_level_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+console_log_level_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
 {
     guint    uval;
 
     uval = (guint)strtoul(value, NULL, 10);
 
     if (*pref->varp.uint != uval) {
 {
     guint    uval;
 
     uval = (guint)strtoul(value, NULL, 10);
 
     if (*pref->varp.uint != uval) {
-        *changed = TRUE;
+        *changed_flags = prefs_get_effect_flags(pref);
         *pref->varp.uint = uval;
     }
 
         *pref->varp.uint = uval;
     }
 
@@ -1506,13 +2398,13 @@ static char * console_log_level_to_str_cb(pref_t* pref, gboolean default_val) {
 static module_t *gui_column_module = NULL;
 
 static prefs_set_pref_e
 static module_t *gui_column_module = NULL;
 
 static prefs_set_pref_e
-column_hidden_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+column_hidden_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
 {
     GList       *clp;
     fmt_data    *cfmt;
     pref_t  *format_pref;
 
 {
     GList       *clp;
     fmt_data    *cfmt;
     pref_t  *format_pref;
 
-    prefs_set_string_like_value(pref, value, changed);
+    (*changed_flags) |= prefs_set_string_value(pref, value, pref_current);
 
     /*
      * Set the "visible" flag for the existing columns; we need to
 
     /*
      * Set the "visible" flag for the existing columns; we need to
@@ -1599,7 +2491,7 @@ column_num_reset_cb(pref_t* pref)
 }
 
 static prefs_set_pref_e
 }
 
 static prefs_set_pref_e
-column_num_set_cb(pref_t* pref _U_, const gchar* value _U_, gboolean* changed _U_)
+column_num_set_cb(pref_t* pref _U_, const gchar* value _U_, unsigned int* changed_flags _U_)
 {
     /* Don't write this to the preferences file */
     return PREFS_SET_OK;
 {
     /* Don't write this to the preferences file */
     return PREFS_SET_OK;
@@ -1699,7 +2591,7 @@ column_format_reset_cb(pref_t* pref)
 }
 
 static prefs_set_pref_e
 }
 
 static prefs_set_pref_e
-column_format_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
+column_format_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags _U_)
 {
     GList    *col_l, *col_l_elt;
     fmt_data *cfmt;
 {
     GList    *col_l, *col_l_elt;
     fmt_data *cfmt;
@@ -1903,7 +2795,7 @@ capture_column_reset_cb(pref_t* pref)
 }
 
 static prefs_set_pref_e
 }
 
 static prefs_set_pref_e
-capture_column_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
+capture_column_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags _U_)
 {
     GList *col_l  = prefs_get_string_list(value);
     GList *col_l_elt;
 {
     GList *col_l  = prefs_get_string_list(value);
     GList *col_l_elt;
@@ -2023,10 +2915,9 @@ capture_column_to_str_cb(pref_t* pref, gboolean default_val)
 }
 
 static prefs_set_pref_e
 }
 
 static prefs_set_pref_e
-colorized_frame_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+colorized_frame_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
 {
 {
-    prefs_set_string_like_value(pref, value, changed);
-
+    (*changed_flags) |= prefs_set_string_value(pref, value, pref_current);
     return PREFS_SET_OK;
 }
 
     return PREFS_SET_OK;
 }
 
@@ -2075,14 +2966,31 @@ prefs_register_modules(void)
 {
     module_t *printing, *capture_module, *console_module,
         *gui_layout_module, *gui_font_module;
 {
     module_t *printing, *capture_module, *console_module,
         *gui_layout_module, *gui_font_module;
+    module_t *extcap_module;
+    unsigned int layout_gui_flags;
     struct pref_custom_cbs custom_cbs;
     struct pref_custom_cbs custom_cbs;
-    gchar *tmp;
 
     if (protocols_module != NULL) {
         /* Already setup preferences */
         return;
     }
 
 
     if (protocols_module != NULL) {
         /* Already setup preferences */
         return;
     }
 
+    /* GUI
+     * These are "simple" GUI preferences that can be read/written using the
+     * preference module API.  These preferences still use their own
+     * configuration screens for access, but this cuts down on the
+     * preference "string compare list" in set_pref()
+     */
+    extcap_module = prefs_register_module(NULL, "extcap", "Extcap Utilities",
+        "Extcap Utilities", NULL, FALSE);
+
+    /* Setting default value to true */
+    prefs.extcap_save_on_start = TRUE;
+    prefs_register_bool_preference(extcap_module, "gui_save_on_start",
+                                   "Save arguments on start of capture",
+                                   "Save arguments on start of capture",
+                                   &prefs.extcap_save_on_start);
+
     /* GUI
      * These are "simple" GUI preferences that can be read/written using the
      * preference module API.  These preferences still use their own
     /* GUI
      * These are "simple" GUI preferences that can be read/written using the
      * preference module API.  These preferences still use their own
@@ -2103,11 +3011,7 @@ prefs_register_modules(void)
     prefs_register_obsolete_preference(gui_module, "scrollbar_on_right");
     prefs_register_obsolete_preference(gui_module, "packet_list_sel_browse");
     prefs_register_obsolete_preference(gui_module, "protocol_tree_sel_browse");
     prefs_register_obsolete_preference(gui_module, "scrollbar_on_right");
     prefs_register_obsolete_preference(gui_module, "packet_list_sel_browse");
     prefs_register_obsolete_preference(gui_module, "protocol_tree_sel_browse");
-
-    prefs_register_bool_preference(gui_module, "tree_view_altern_colors",
-                                   "Alternating colors in TreeViews",
-                                   "Alternating colors in TreeViews?",
-                                   &prefs.gui_altern_colors);
+    prefs_register_obsolete_preference(gui_module, "tree_view_altern_colors");
 
     prefs_register_bool_preference(gui_module, "expert_composite_eyecandy",
                                    "Display Icons on Expert Composite Dialog Tabs",
 
     prefs_register_bool_preference(gui_module, "expert_composite_eyecandy",
                                    "Display Icons on Expert Composite Dialog Tabs",
@@ -2119,6 +3023,11 @@ prefs_register_modules(void)
                                    "Place filter toolbar inside the statusbar?",
                                    &prefs.filter_toolbar_show_in_statusbar);
 
                                    "Place filter toolbar inside the statusbar?",
                                    &prefs.filter_toolbar_show_in_statusbar);
 
+    prefs_register_bool_preference(gui_module, "restore_filter_after_following_stream",
+                                   "Restore current display filter after following a stream",
+                                   "Restore current display filter after following a stream?",
+                                   &prefs.restore_filter_after_following_stream);
+
     prefs_register_enum_preference(gui_module, "protocol_tree_line_style",
                        "Protocol-tree line style",
                        "Protocol-tree line style",
     prefs_register_enum_preference(gui_module, "protocol_tree_line_style",
                        "Protocol-tree line style",
                        "Protocol-tree line style",
@@ -2129,10 +3038,7 @@ prefs_register_modules(void)
                        "Protocol-tree expander style",
                        &prefs.gui_ptree_expander_style, gui_ptree_expander_style, FALSE);
 
                        "Protocol-tree expander style",
                        &prefs.gui_ptree_expander_style, gui_ptree_expander_style, FALSE);
 
-    prefs_register_enum_preference(gui_module, "hex_dump_highlight_style",
-                       "Hex dump highlight style",
-                       "Hex dump highlight style",
-                       &prefs.gui_hex_dump_highlight_style, gui_hex_dump_highlight_style, FALSE);
+    prefs_register_obsolete_preference(gui_module, "hex_dump_highlight_style");
 
     gui_column_module = prefs_register_subtree(gui_module, "Columns", "Columns", NULL);
 
 
     gui_column_module = prefs_register_subtree(gui_module, "Columns", "Columns", NULL);
 
@@ -2143,8 +3049,9 @@ prefs_register_modules(void)
     custom_cbs.type_description_cb = column_hidden_type_description_cb;
     custom_cbs.is_default_cb = column_hidden_is_default_cb;
     custom_cbs.to_str_cb = column_hidden_to_str_cb;
     custom_cbs.type_description_cb = column_hidden_type_description_cb;
     custom_cbs.is_default_cb = column_hidden_is_default_cb;
     custom_cbs.to_str_cb = column_hidden_to_str_cb;
-    prefs_register_string_custom_preference(gui_column_module, PRS_COL_HIDDEN, "Packet list hidden columns",
-        "List all columns to hide in the packet list", &custom_cbs, (const char **)&cols_hidden_list);
+    register_string_like_preference(gui_column_module, PRS_COL_HIDDEN, "Packet list hidden columns",
+        "List all columns to hide in the packet list",
+        &cols_hidden_list, PREF_CUSTOM, &custom_cbs, FALSE);
 
     custom_cbs.free_cb = column_format_free_cb;
     custom_cbs.reset_cb = column_format_reset_cb;
 
     custom_cbs.free_cb = column_format_free_cb;
     custom_cbs.reset_cb = column_format_reset_cb;
@@ -2176,15 +3083,11 @@ prefs_register_modules(void)
 
     prefs_register_obsolete_preference(gui_font_module, "font_name");
 
 
     prefs_register_obsolete_preference(gui_font_module, "font_name");
 
-    tmp = prefs.gui_gtk2_font_name;
-    prefs_register_string_preference(gui_font_module, "gtk2.font_name", "Font name",
-        "Font name for packet list, protocol tree, and hex dump panes. (GTK+)", (const char **)&prefs.gui_gtk2_font_name);
-    g_free(tmp);
+    prefs_register_obsolete_preference(gui_font_module, "gtk2.font_name");
 
 
-    tmp = prefs.gui_qt_font_name;
-    prefs_register_string_preference(gui_font_module, "qt.font_name", "Font name",
-        "Font name for packet list, protocol tree, and hex dump panes. (Qt)", (const char **)&prefs.gui_qt_font_name);
-    g_free(tmp);
+    register_string_like_preference(gui_font_module, "qt.font_name", "Font name",
+        "Font name for packet list, protocol tree, and hex dump panes. (Qt)",
+        &prefs.gui_qt_font_name, PREF_STRING, NULL, TRUE);
 
     /* User Interface : Colors */
     gui_color_module = prefs_register_subtree(gui_module, "Colors", "Colors", NULL);
 
     /* User Interface : Colors */
     gui_color_module = prefs_register_subtree(gui_module, "Colors", "Colors", NULL);
@@ -2220,10 +3123,9 @@ prefs_register_modules(void)
     custom_cbs.type_description_cb = colorized_frame_type_description_cb;
     custom_cbs.is_default_cb = colorized_frame_is_default_cb;
     custom_cbs.to_str_cb = colorized_frame_to_str_cb;
     custom_cbs.type_description_cb = colorized_frame_type_description_cb;
     custom_cbs.is_default_cb = colorized_frame_is_default_cb;
     custom_cbs.to_str_cb = colorized_frame_to_str_cb;
-    tmp = prefs.gui_colorized_fg;
-    prefs_register_string_custom_preference(gui_column_module, "colorized_frame.fg", "Colorized Foreground",
-        "Filter Colorized Foreground", &custom_cbs, (const char **)&prefs.gui_colorized_fg);
-    g_free(tmp);
+    register_string_like_preference(gui_column_module, "colorized_frame.fg", "Colorized Foreground",
+        "Filter Colorized Foreground",
+        &prefs.gui_colorized_fg, PREF_CUSTOM, &custom_cbs, TRUE);
 
     custom_cbs.free_cb = free_string_like_preference;
     custom_cbs.reset_cb = reset_string_like_preference;
 
     custom_cbs.free_cb = free_string_like_preference;
     custom_cbs.reset_cb = reset_string_like_preference;
@@ -2232,10 +3134,9 @@ prefs_register_modules(void)
     custom_cbs.type_description_cb = colorized_frame_type_description_cb;
     custom_cbs.is_default_cb = colorized_frame_is_default_cb;
     custom_cbs.to_str_cb = colorized_frame_to_str_cb;
     custom_cbs.type_description_cb = colorized_frame_type_description_cb;
     custom_cbs.is_default_cb = colorized_frame_is_default_cb;
     custom_cbs.to_str_cb = colorized_frame_to_str_cb;
-    tmp = prefs.gui_colorized_bg;
-    prefs_register_string_custom_preference(gui_column_module, "colorized_frame.bg", "Colorized Background",
-        "Filter Colorized Background", &custom_cbs, (const char **)&prefs.gui_colorized_bg);
-    g_free(tmp);
+    register_string_like_preference(gui_column_module, "colorized_frame.bg", "Colorized Background",
+        "Filter Colorized Background",
+        &prefs.gui_colorized_bg, PREF_CUSTOM, &custom_cbs, TRUE);
 
     prefs_register_color_preference(gui_color_module, "color_filter_bg.valid", "Valid color filter background",
         "Valid color filter background", &prefs.gui_text_valid);
 
     prefs_register_color_preference(gui_color_module, "color_filter_bg.valid", "Valid color filter background",
         "Valid color filter background", &prefs.gui_text_valid);
@@ -2263,10 +3164,9 @@ prefs_register_modules(void)
                                    10,
                                    &prefs.gui_recent_df_entries_max);
 
                                    10,
                                    &prefs.gui_recent_df_entries_max);
 
-    tmp = prefs.gui_fileopen_dir;
-    prefs_register_directory_preference(gui_module, "fileopen.dir", "Start Directory",
-        "Directory to start in when opening File Open dialog.", (const char **)&prefs.gui_fileopen_dir);
-    g_free(tmp);
+    register_string_like_preference(gui_module, "fileopen.dir", "Start Directory",
+        "Directory to start in when opening File Open dialog.",
+        &prefs.gui_fileopen_dir, PREF_DIRNAME, NULL, TRUE);
 
     prefs_register_obsolete_preference(gui_module, "fileopen.remembered_dir");
 
 
     prefs_register_obsolete_preference(gui_module, "fileopen.remembered_dir");
 
@@ -2306,11 +3206,7 @@ prefs_register_modules(void)
                                    "Save window maximized state at exit?",
                                    &prefs.gui_geometry_save_maximized);
 
                                    "Save window maximized state at exit?",
                                    &prefs.gui_geometry_save_maximized);
 
-    /* GTK+ only */
-    prefs_register_bool_preference(gui_module, "macosx_style",
-                                   "Use OS X style",
-                                   "Use OS X style (OS X with native GTK only)?",
-                                   &prefs.gui_macosx_style);
+    prefs_register_obsolete_preference(gui_module, "macosx_style");
 
     prefs_register_obsolete_preference(gui_module, "geometry.main.x");
     prefs_register_obsolete_preference(gui_module, "geometry.main.y");
 
     prefs_register_obsolete_preference(gui_module, "geometry.main.x");
     prefs_register_obsolete_preference(gui_module, "geometry.main.y");
@@ -2328,10 +3224,9 @@ prefs_register_modules(void)
                        "Filter Toolbar style",
                        &prefs.gui_toolbar_filter_style, gui_toolbar_style, FALSE);
 
                        "Filter Toolbar style",
                        &prefs.gui_toolbar_filter_style, gui_toolbar_style, FALSE);
 
-    tmp = prefs.gui_webbrowser;
-    prefs_register_string_preference(gui_module, "webbrowser", "The path to the webbrowser",
-        "The path to the webbrowser (Ex: mozilla)", (const char **)&prefs.gui_webbrowser);
-    g_free(tmp);
+    register_string_like_preference(gui_module, "webbrowser", "The path to the webbrowser",
+        "The path to the webbrowser (Ex: mozilla)",
+        &prefs.gui_webbrowser, PREF_STRING, NULL, TRUE);
 
     prefs_register_bool_preference(gui_module, "update.enabled",
                                    "Check for updates",
 
     prefs_register_bool_preference(gui_module, "update.enabled",
                                    "Check for updates",
@@ -2349,61 +3244,73 @@ prefs_register_modules(void)
                                    10,
                                    &prefs.gui_update_interval);
 
                                    10,
                                    &prefs.gui_update_interval);
 
-    tmp = prefs.gui_window_title;
-    prefs_register_string_preference(gui_module, "window_title", "Custom window title",
-        "Custom window title. (Appended to existing titles.)", (const char **)&prefs.gui_window_title);
-    g_free(tmp);
+    register_string_like_preference(gui_module, "window_title", "Custom window title",
+        "Custom window title to be appended to the existing title\n%P = profile name\n%V = version info",
+        &prefs.gui_window_title, PREF_STRING, NULL, TRUE);
 
 
-    tmp = prefs.gui_start_title;
-    prefs_register_string_preference(gui_module, "start_title", "Custom start page title",
-        "Custom start page title", (const char**)(&prefs.gui_start_title));
-    g_free(tmp);
+    register_string_like_preference(gui_module, "prepend_window_title", "Custom window title prefix",
+        "Custom window title to be prepended to the existing title\n%P = profile name\n%V = version info",
+        &prefs.gui_prepend_window_title, PREF_STRING, NULL, TRUE);
+
+    register_string_like_preference(gui_module, "start_title", "Custom start page title",
+        "Custom start page title",
+        &prefs.gui_start_title, PREF_STRING, NULL, TRUE);
 
     prefs_register_enum_preference(gui_module, "version_placement",
                        "Show version in the start page and/or main screen's title bar",
                        "Show version in the start page and/or main screen's title bar",
                        (gint*)(void*)(&prefs.gui_version_placement), gui_version_placement_type, FALSE);
 
 
     prefs_register_enum_preference(gui_module, "version_placement",
                        "Show version in the start page and/or main screen's title bar",
                        "Show version in the start page and/or main screen's title bar",
                        (gint*)(void*)(&prefs.gui_version_placement), gui_version_placement_type, FALSE);
 
-    prefs_register_bool_preference(gui_module, "auto_scroll_on_expand",
-                                   "Automatically scroll the recently expanded item",
-                                   "Automatically scroll the recently expanded item",
-                                   &prefs.gui_auto_scroll_on_expand);
-
-    prefs_register_uint_preference(gui_module, "auto_scroll_percentage",
-                                   "The percentage down the view the recently expanded item should be scrolled",
-                                   "The percentage down the view the recently expanded item should be scrolled",
-                                   10,
-                                   &prefs.gui_auto_scroll_percentage);
+    prefs_register_obsolete_preference(gui_module, "auto_scroll_on_expand");
+    prefs_register_obsolete_preference(gui_module, "auto_scroll_percentage");
 
     /* User Interface : Layout */
     gui_layout_module = prefs_register_subtree(gui_module, "Layout", "Layout", gui_layout_callback);
 
     /* User Interface : Layout */
     gui_layout_module = prefs_register_subtree(gui_module, "Layout", "Layout", gui_layout_callback);
+    /* Adjust the preference effects of layout GUI for better handling of preferences at Wireshark (GUI) level */
+    layout_gui_flags = prefs_get_module_effect_flags(gui_layout_module);
+    layout_gui_flags |= PREF_EFFECT_GUI_LAYOUT;
+    layout_gui_flags &= (~PREF_EFFECT_DISSECTION);
 
     prefs_register_uint_preference(gui_layout_module, "layout_type",
                                    "Layout type",
                                    "Layout type (1-6)",
                                    10,
                                    (guint*)(void*)(&prefs.gui_layout_type));
 
     prefs_register_uint_preference(gui_layout_module, "layout_type",
                                    "Layout type",
                                    "Layout type (1-6)",
                                    10,
                                    (guint*)(void*)(&prefs.gui_layout_type));
+    prefs_set_effect_flags_by_name(gui_layout_module, "layout_type", layout_gui_flags);
 
     prefs_register_enum_preference(gui_layout_module, "layout_content_1",
                        "Layout content of the pane 1",
                        "Layout content of the pane 1",
                        (gint*)(void*)(&prefs.gui_layout_content_1), gui_layout_content, FALSE);
 
     prefs_register_enum_preference(gui_layout_module, "layout_content_1",
                        "Layout content of the pane 1",
                        "Layout content of the pane 1",
                        (gint*)(void*)(&prefs.gui_layout_content_1), gui_layout_content, FALSE);
+    prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_1", layout_gui_flags);
 
     prefs_register_enum_preference(gui_layout_module, "layout_content_2",
                        "Layout content of the pane 2",
                        "Layout content of the pane 2",
                        (gint*)(void*)(&prefs.gui_layout_content_2), gui_layout_content, FALSE);
 
     prefs_register_enum_preference(gui_layout_module, "layout_content_2",
                        "Layout content of the pane 2",
                        "Layout content of the pane 2",
                        (gint*)(void*)(&prefs.gui_layout_content_2), gui_layout_content, FALSE);
+    prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_2", layout_gui_flags);
 
     prefs_register_enum_preference(gui_layout_module, "layout_content_3",
                        "Layout content of the pane 3",
                        "Layout content of the pane 3",
                        (gint*)(void*)(&prefs.gui_layout_content_3), gui_layout_content, FALSE);
 
     prefs_register_enum_preference(gui_layout_module, "layout_content_3",
                        "Layout content of the pane 3",
                        "Layout content of the pane 3",
                        (gint*)(void*)(&prefs.gui_layout_content_3), gui_layout_content, FALSE);
+    prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_3", layout_gui_flags);
 
     prefs_register_bool_preference(gui_layout_module, "packet_list_separator.enabled",
                                    "Enable Packet List Separator",
                                    "Enable Packet List Separator",
                                    &prefs.gui_qt_packet_list_separator);
 
 
     prefs_register_bool_preference(gui_layout_module, "packet_list_separator.enabled",
                                    "Enable Packet List Separator",
                                    "Enable Packet List Separator",
                                    &prefs.gui_qt_packet_list_separator);
 
+    prefs_register_bool_preference(gui_layout_module, "show_selected_packet.enabled",
+                                   "Show selected packet in the Status Bar",
+                                   "Show selected packet in the Status Bar",
+                                   &prefs.gui_qt_show_selected_packet);
+
+    prefs_register_bool_preference(gui_layout_module, "show_file_load_time.enabled",
+                                   "Show file load time in the Status Bar",
+                                   "Show file load time in the Status Bar",
+                                   &prefs.gui_qt_show_file_load_time);
+
     prefs_register_bool_preference(gui_module, "packet_editor.enabled",
                                    "Enable Packet Editor",
                                    "Enable Packet Editor (Experimental)",
     prefs_register_bool_preference(gui_module, "packet_editor.enabled",
                                    "Enable Packet Editor",
                                    "Enable Packet Editor (Experimental)",
@@ -2424,6 +3331,23 @@ prefs_register_modules(void)
                                    "Show the intelligent scroll bar (a minimap of packet list colors in the scrollbar)",
                                    &prefs.gui_packet_list_show_minimap);
 
                                    "Show the intelligent scroll bar (a minimap of packet list colors in the scrollbar)",
                                    &prefs.gui_packet_list_show_minimap);
 
+
+    prefs_register_bool_preference(gui_module, "interfaces_show_hidden",
+                                   "Show hidden interfaces",
+                                   "Show all interfaces, including interfaces marked as hidden",
+                                   &prefs.gui_interfaces_show_hidden);
+
+#ifdef HAVE_PCAP_REMOTE
+    prefs_register_bool_preference(gui_module, "interfaces_remote_display",
+                                   "Show Remote interfaces",
+                                   "Show remote interfaces in the interface selection",
+                                   &prefs.gui_interfaces_remote_display);
+#endif
+
+    register_string_like_preference(gui_module, "interfaces_hidden_types", "Hide interface types in list",
+        "Hide the given interface types in the startup list",
+        &prefs.gui_interfaces_hide_types, PREF_STRING, NULL, TRUE);
+
     /* Console
      * These are preferences that can be read/written using the
      * preference module API.  These preferences still use their own
     /* Console
      * These are preferences that can be read/written using the
      * preference module API.  These preferences still use their own
@@ -2431,7 +3355,7 @@ prefs_register_modules(void)
      * preference "string compare list" in set_pref()
      */
     console_module = prefs_register_module(NULL, "console", "Console",
      * preference "string compare list" in set_pref()
      */
     console_module = prefs_register_module(NULL, "console", "Console",
-        "CONSOLE", NULL, FALSE);
+        "Console logging and debugging output", NULL, FALSE);
 
     custom_cbs.free_cb = custom_pref_no_cb;
     custom_cbs.reset_cb = console_log_level_reset_cb;
 
     custom_cbs.free_cb = custom_pref_no_cb;
     custom_cbs.reset_cb = console_log_level_reset_cb;
@@ -2441,7 +3365,20 @@ prefs_register_modules(void)
     custom_cbs.is_default_cb = console_log_level_is_default_cb;
     custom_cbs.to_str_cb = console_log_level_to_str_cb;
     prefs_register_uint_custom_preference(console_module, "log.level", "logging level",
     custom_cbs.is_default_cb = console_log_level_is_default_cb;
     custom_cbs.to_str_cb = console_log_level_to_str_cb;
     prefs_register_uint_custom_preference(console_module, "log.level", "logging level",
-        "A bitmask of glib log levels", &custom_cbs, &prefs.console_log_level);
+        "A bitmask of GLib log levels", &custom_cbs, &prefs.console_log_level);
+
+    prefs_register_bool_preference(console_module, "incomplete_dissectors_check_debug",
+                                   "Print debug line for incomplete dissectors",
+                                   "Look for dissectors that left some bytes undecoded (debug)",
+                                   &prefs.incomplete_dissectors_check_debug);
+
+    /* Display filter Expressions
+     * This used to be an array of individual fields that has now been
+     * converted to a UAT.  Just make it part of the GUI category even
+     * though the name of the preference will never be seen in preference
+     * file
+     */
+    filter_expression_register_uat(gui_module);
 
     /* Capture
      * These are preferences that can be read/written using the
 
     /* Capture
      * These are preferences that can be read/written using the
@@ -2450,58 +3387,65 @@ prefs_register_modules(void)
      * preference "string compare list" in set_pref()
      */
     capture_module = prefs_register_module(NULL, "capture", "Capture",
      * preference "string compare list" in set_pref()
      */
     capture_module = prefs_register_module(NULL, "capture", "Capture",
-        "CAPTURE", NULL, FALSE);
+        "Capture preferences", NULL, FALSE);
+    /* Capture preferences don't affect dissection */
+    prefs_set_module_effect_flags(capture_module, PREF_EFFECT_CAPTURE);
 
 
-    prefs_register_string_preference(capture_module, "device", "Default capture device",
-        "Default capture device", (const char **)&prefs.capture_device);
+    register_string_like_preference(capture_module, "device", "Default capture device",
+        "Default capture device",
+        &prefs.capture_device, PREF_STRING, NULL, FALSE);
 
 
-    prefs_register_string_preference(capture_module, "devices_linktypes", "Interface link-layer header type",
+    register_string_like_preference(capture_module, "devices_linktypes", "Interface link-layer header type",
         "Interface link-layer header types (Ex: en0(1),en1(143),...)",
         "Interface link-layer header types (Ex: en0(1),en1(143),...)",
-        (const char **)&prefs.capture_devices_linktypes);
+        &prefs.capture_devices_linktypes, PREF_STRING, NULL, FALSE);
 
 
-    prefs_register_string_preference(capture_module, "devices_descr", "Interface descriptions",
+    register_string_like_preference(capture_module, "devices_descr", "Interface descriptions",
         "Interface descriptions (Ex: eth0(eth0 descr),eth1(eth1 descr),...)",
         "Interface descriptions (Ex: eth0(eth0 descr),eth1(eth1 descr),...)",
-        (const char **)&prefs.capture_devices_descr);
+        &prefs.capture_devices_descr, PREF_STRING, NULL, FALSE);
 
 
-    prefs_register_string_preference(capture_module, "devices_hide", "Hide interface",
-        "Hide interface? (Ex: eth0,eth3,...)", (const char **)&prefs.capture_devices_hide);
+    register_string_like_preference(capture_module, "devices_hide", "Hide interface",
+        "Hide interface? (Ex: eth0,eth3,...)",
+        &prefs.capture_devices_hide, PREF_STRING, NULL, FALSE);
 
 
-    prefs_register_string_preference(capture_module, "devices_monitor_mode", "Capture in monitor mode",
+    register_string_like_preference(capture_module, "devices_monitor_mode", "Capture in monitor mode",
         "By default, capture in monitor mode on interface? (Ex: eth0,eth3,...)",
         "By default, capture in monitor mode on interface? (Ex: eth0,eth3,...)",
-        (const char **)&prefs.capture_devices_monitor_mode);
+        &prefs.capture_devices_monitor_mode, PREF_STRING, NULL, FALSE);
 
 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
 
 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
-    prefs_register_string_preference(capture_module, "devices_buffersize", "Interface buffer size",
+    register_string_like_preference(capture_module, "devices_buffersize", "Interface buffer size",
         "Interface buffer size (Ex: en0(1),en1(143),...)",
         "Interface buffer size (Ex: en0(1),en1(143),...)",
-        ((const char **)&prefs.capture_devices_buffersize));
+        &prefs.capture_devices_buffersize, PREF_STRING, NULL, FALSE);
 #endif
 
 #endif
 
-    prefs_register_string_preference(capture_module, "devices_snaplen", "Interface snap length",
+    register_string_like_preference(capture_module, "devices_snaplen", "Interface snap length",
         "Interface snap length (Ex: en0(65535),en1(1430),...)",
         "Interface snap length (Ex: en0(65535),en1(1430),...)",
-        (const char **)&prefs.capture_devices_snaplen);
+        &prefs.capture_devices_snaplen, PREF_STRING, NULL, FALSE);
 
 
-    prefs_register_string_preference(capture_module, "devices_pmode", "Interface promiscuous mode",
+    register_string_like_preference(capture_module, "devices_pmode", "Interface promiscuous mode",
         "Interface promiscuous mode (Ex: en0(0),en1(1),...)",
         "Interface promiscuous mode (Ex: en0(0),en1(1),...)",
-        (const char **)&prefs.capture_devices_pmode);
+        &prefs.capture_devices_pmode, PREF_STRING, NULL, FALSE);
 
     prefs_register_bool_preference(capture_module, "prom_mode", "Capture in promiscuous mode",
         "Capture in promiscuous mode?", &prefs.capture_prom_mode);
 
 
     prefs_register_bool_preference(capture_module, "prom_mode", "Capture in promiscuous mode",
         "Capture in promiscuous mode?", &prefs.capture_prom_mode);
 
-    prefs_register_string_preference(capture_module, "devices_filter", "Interface capture filter",
+    register_string_like_preference(capture_module, "devices_filter", "Interface capture filter",
         "Interface capture filter (Ex: en0(tcp),en1(udp),...)",
         "Interface capture filter (Ex: en0(tcp),en1(udp),...)",
-        (const char **)&prefs.capture_devices_filter);
+        &prefs.capture_devices_filter, PREF_STRING, NULL, FALSE);
 
 
-    prefs_register_bool_preference(capture_module, "pcap_ng", "Capture in Pcap-NG format",
-        "Capture in Pcap-NG format?", &prefs.capture_pcap_ng);
+    prefs_register_bool_preference(capture_module, "pcap_ng", "Capture in pcapng format",
+        "Capture in pcapng format?", &prefs.capture_pcap_ng);
 
     prefs_register_bool_preference(capture_module, "real_time_update", "Update packet list in real time during capture",
         "Update packet list in real time during capture?", &prefs.capture_real_time);
 
 
     prefs_register_bool_preference(capture_module, "real_time_update", "Update packet list in real time during capture",
         "Update packet list in real time during capture?", &prefs.capture_real_time);
 
+    prefs_register_bool_preference(capture_module, "no_extcap", "Disable external capture interfaces",
+        "Disable external capture modules (extcap)", &prefs.capture_no_extcap);
+
     /* We might want to make this a "recent" setting. */
     prefs_register_bool_preference(capture_module, "auto_scroll", "Scroll packet list during capture",
         "Scroll packet list during capture?", &prefs.capture_auto_scroll);
 
     /* We might want to make this a "recent" setting. */
     prefs_register_bool_preference(capture_module, "auto_scroll", "Scroll packet list during capture",
         "Scroll packet list during capture?", &prefs.capture_auto_scroll);
 
-    /* GTK+ only */
+    /* GTK+ only, but we might implement this in Qt */
     prefs_register_bool_preference(capture_module, "show_info", "Show capture info dialog while capturing",
         "Show capture info dialog while capturing?", &prefs.capture_show_info);
 
     prefs_register_bool_preference(capture_module, "show_info", "Show capture info dialog while capturing",
         "Show capture info dialog while capturing?", &prefs.capture_show_info);
 
@@ -2522,9 +3466,7 @@ prefs_register_modules(void)
         "Name Resolution", NULL, TRUE);
     addr_resolve_pref_init(nameres_module);
     oid_pref_init(nameres_module);
         "Name Resolution", NULL, TRUE);
     addr_resolve_pref_init(nameres_module);
     oid_pref_init(nameres_module);
-#ifdef HAVE_GEOIP
-    geoip_db_pref_init(nameres_module);
-#endif
+    maxmind_db_pref_init(nameres_module);
 
     /* Printing */
     printing = prefs_register_module(NULL, "print", "Printing",
 
     /* Printing */
     printing = prefs_register_module(NULL, "print", "Printing",
@@ -2539,16 +3481,18 @@ prefs_register_modules(void)
                                    &prefs.pr_dest, print_dest_vals, TRUE);
 
 #ifndef _WIN32
                                    &prefs.pr_dest, print_dest_vals, TRUE);
 
 #ifndef _WIN32
-    tmp = prefs.pr_cmd;
-    prefs_register_string_preference(printing, "command", "Command",
-        "Output gets piped to this command when the destination is set to \"command\"", (const char**)(&prefs.pr_cmd));
-    g_free(tmp);
+    register_string_like_preference(printing, "command", "Command",
+        "Output gets piped to this command when the destination is set to \"command\"",
+        &prefs.pr_cmd, PREF_STRING, NULL, TRUE);
 #endif
 
 #endif
 
-    tmp = prefs.pr_file;
-    prefs_register_filename_preference(printing, "file", "File",
-        "This is the file that gets written to when the destination is set to \"file\"", (const char**)(&prefs.pr_file));
-    g_free(tmp);
+    register_string_like_preference(printing, "file", "File",
+        "This is the file that gets written to when the destination is set to \"file\"",
+        &prefs.pr_file, PREF_SAVE_FILENAME, NULL, TRUE);
+
+    /* Codecs */
+    codecs_module = prefs_register_module(NULL, "codecs", "Codecs",
+        "Codecs", NULL, TRUE);
 
     /* Statistics */
     stats_module = prefs_register_module(NULL, "statistics", "Statistics",
 
     /* Statistics */
     stats_module = prefs_register_module(NULL, "statistics", "Statistics",
@@ -2560,13 +3504,7 @@ prefs_register_modules(void)
                                    10,
                                    &prefs.tap_update_interval);
 
                                    10,
                                    &prefs.tap_update_interval);
 
-#ifdef HAVE_LIBPORTAUDIO
-    prefs_register_uint_preference(stats_module, "rtp_player_max_visible",
-                                   "Max visible channels in RTP Player",
-                                   "Determines maximum height of RTP Player window",
-                                   10,
-                                   &prefs.rtp_player_max_visible);
-#endif
+    prefs_register_obsolete_preference(stats_module, "rtp_player_max_visible");
 
     prefs_register_bool_preference(stats_module, "st_enable_burstinfo",
             "Enable the calculation of burst information",
 
     prefs_register_bool_preference(stats_module, "st_enable_burstinfo",
             "Enable the calculation of burst information",
@@ -2655,6 +3593,12 @@ prefs_register_modules(void)
                                    "Look for dissectors that left some bytes undecoded.",
                                    &prefs.enable_incomplete_dissectors_check);
 
                                    "Look for dissectors that left some bytes undecoded.",
                                    &prefs.enable_incomplete_dissectors_check);
 
+    prefs_register_bool_preference(protocols_module, "strict_conversation_tracking_heuristics",
+                                   "Enable stricter conversation tracking heuristics",
+                                   "Protocols may use things like VLAN ID or interface ID to narrow the potential for duplicate conversations."
+                                   "Currently only ICMP and ICMPv6 use this preference to add VLAN ID to conversation tracking",
+                                   &prefs.strict_conversation_tracking_heuristics);
+
     /* Obsolete preferences
      * These "modules" were reorganized/renamed to correspond to their GUI
      * configuration screen within the preferences dialog
     /* Obsolete preferences
      * These "modules" were reorganized/renamed to correspond to their GUI
      * configuration screen within the preferences dialog
@@ -2699,7 +3643,10 @@ prefs_get_string_list(const gchar *str)
                 return NULL;
             }
             slstr[j] = '\0';
                 return NULL;
             }
             slstr[j] = '\0';
-            sl = g_list_append(sl, slstr);
+            if (j > 0)
+                sl = g_list_append(sl, slstr);
+            else
+                g_free(slstr);
             break;
         }
         if (cur_c == '"' && ! backslash) {
             break;
         }
         if (cur_c == '"' && ! backslash) {
@@ -2735,11 +3682,13 @@ prefs_get_string_list(const gchar *str)
                and it wasn't preceded by a backslash; it's the end of
                the string we were working on...  */
             slstr[j] = '\0';
                and it wasn't preceded by a backslash; it's the end of
                the string we were working on...  */
             slstr[j] = '\0';
-            sl = g_list_append(sl, slstr);
+            if (j > 0) {
+                sl = g_list_append(sl, slstr);
+                slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+            }
 
             /* ...and the beginning of a new string.  */
             state = PRE_STRING;
 
             /* ...and the beginning of a new string.  */
             state = PRE_STRING;
-            slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
             j = 0;
         } else if (!g_ascii_isspace(cur_c) || state != PRE_STRING) {
             /* Either this isn't a white-space character, or we've started a
             j = 0;
         } else if (!g_ascii_isspace(cur_c) || state != PRE_STRING) {
             /* Either this isn't a white-space character, or we've started a
@@ -2766,7 +3715,6 @@ char *join_string_list(GList *sl)
     GString      *joined_str = g_string_new("");
     GList        *cur, *first;
     gchar        *str;
     GString      *joined_str = g_string_new("");
     GList        *cur, *first;
     gchar        *str;
-    gchar        *quoted_str;
     guint         item_count = 0;
 
     cur = first = g_list_first(sl);
     guint         item_count = 0;
 
     cur = first = g_list_first(sl);
@@ -2783,9 +3731,20 @@ char *join_string_list(GList *sl)
         } else
             g_string_append_c(joined_str, ' ');
 
         } else
             g_string_append_c(joined_str, ' ');
 
-        quoted_str = g_strescape(str, "");
-        g_string_append_printf(joined_str, "\"%s\"", quoted_str);
-        g_free(quoted_str);
+        g_string_append_c(joined_str, '"');
+        while (*str) {
+            gunichar uc = g_utf8_get_char (str);
+
+            if (uc == '"' || uc == '\\')
+                g_string_append_c(joined_str, '\\');
+
+            if (g_unichar_isprint(uc))
+                g_string_append_unichar (joined_str, uc);
+
+            str = g_utf8_next_char (str);
+        }
+
+        g_string_append_c(joined_str, '"');
 
         cur = cur->next;
     }
 
         cur = cur->next;
     }
@@ -2837,6 +3796,45 @@ find_val_for_string(const char *needle, const enum_val_t *haystack,
     return default_value;
 }
 
     return default_value;
 }
 
+
+/* Array of columns that have been migrated to custom columns */
+struct deprecated_columns {
+    const gchar *col_fmt;
+    const gchar *col_expr;
+};
+static struct deprecated_columns migrated_columns[] = {
+    { /* COL_COS_VALUE */ "%U", "vlan.priority" },
+    { /* COL_CIRCUIT_ID */ "%c", "iax2.call" },
+    { /* COL_BSSGP_TLLI */ "%l", "bssgp.tlli" },
+    { /* COL_HPUX_SUBSYS */ "%H", "nettl.subsys" },
+    { /* COL_HPUX_DEVID */ "%P", "nettl.devid" },
+    { /* COL_FR_DLCI */ "%C", "fr.dlci" },
+    { /* COL_REL_CONV_TIME */ "%rct", "tcp.time_relative" },
+    { /* COL_DELTA_CONV_TIME */ "%dct", "tcp.time_delta" },
+    { /* COL_OXID */ "%XO", "fc.ox_id" },
+    { /* COL_RXID */ "%XR", "fc.rx_id" },
+    { /* COL_SRCIDX */ "%Xd", "mdshdr.srcidx" },
+    { /* COL_DSTIDX */ "%Xs", "mdshdr.dstidx" },
+    { /* COL_DCE_CTX */ "%z", "dcerpc.cn_ctx_id" }
+};
+
+static gboolean
+is_deprecated_column_format(const gchar* fmt)
+{
+    guint haystack_idx;
+
+    for (haystack_idx = 0;
+         haystack_idx < G_N_ELEMENTS(migrated_columns);
+         ++haystack_idx) {
+
+        if (strcmp(migrated_columns[haystack_idx].col_fmt, fmt) == 0) {
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
 /* Preferences file format:
  * - Configuration directives start at the beginning of the line, and
  *   are terminated with a colon.
 /* Preferences file format:
  * - Configuration directives start at the beginning of the line, and
  *   are terminated with a colon.
@@ -2893,7 +3891,7 @@ parse_column_format(fmt_data *cfmt, const char *fmt)
         g_strfreev(cust_format_info);
     } else {
         col_fmt = get_column_format_from_str(fmt);
         g_strfreev(cust_format_info);
     } else {
         col_fmt = get_column_format_from_str(fmt);
-        if (col_fmt == -1)
+        if ((col_fmt == -1) && (!is_deprecated_column_format(fmt)))
             return FALSE;
     }
 
             return FALSE;
     }
 
@@ -2926,8 +3924,6 @@ init_prefs(void)
 
     prefs_register_modules();
 
 
     prefs_register_modules();
 
-    filter_expression_init();
-
     prefs_initialized = TRUE;
 }
 
     prefs_initialized = TRUE;
 }
 
@@ -2952,86 +3948,82 @@ pre_init_prefs(void)
 
     prefs.pr_format  = PR_FMT_TEXT;
     prefs.pr_dest    = PR_DEST_CMD;
 
     prefs.pr_format  = PR_FMT_TEXT;
     prefs.pr_dest    = PR_DEST_CMD;
-    if (prefs.pr_file) g_free(prefs.pr_file);
+    g_free(prefs.pr_file);
     prefs.pr_file    = g_strdup("wireshark.out");
     prefs.pr_file    = g_strdup("wireshark.out");
-    if (prefs.pr_cmd) g_free(prefs.pr_cmd);
+    g_free(prefs.pr_cmd);
     prefs.pr_cmd     = g_strdup("lpr");
 
     prefs.pr_cmd     = g_strdup("lpr");
 
-    prefs.gui_altern_colors = FALSE;
     prefs.gui_expert_composite_eyecandy = FALSE;
     prefs.gui_ptree_line_style = 0;
     prefs.gui_ptree_expander_style = 1;
     prefs.gui_expert_composite_eyecandy = FALSE;
     prefs.gui_ptree_line_style = 0;
     prefs.gui_ptree_expander_style = 1;
-    prefs.gui_hex_dump_highlight_style = 1;
     prefs.filter_toolbar_show_in_statusbar = FALSE;
     prefs.filter_toolbar_show_in_statusbar = FALSE;
+    prefs.restore_filter_after_following_stream = FALSE;
     prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
     prefs.gui_toolbar_filter_style = TB_STYLE_TEXT;
     prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
     prefs.gui_toolbar_filter_style = TB_STYLE_TEXT;
-    /* These will be g_freed, so they must be g_mallocated. */
-    if (prefs.gui_gtk2_font_name) g_free(prefs.gui_gtk2_font_name);
-#ifdef _WIN32
-    prefs.gui_gtk2_font_name         = g_strdup("Lucida Console 10");
-#else
-    prefs.gui_gtk2_font_name         = g_strdup("Monospace 10");
-#endif
     /* We try to find the best font in the Qt code */
     /* We try to find the best font in the Qt code */
-    if (prefs.gui_qt_font_name) g_free(prefs.gui_qt_font_name);
+    g_free(prefs.gui_qt_font_name);
     prefs.gui_qt_font_name           = g_strdup("");
     prefs.gui_qt_font_name           = g_strdup("");
-    prefs.gui_marked_fg.pixel        =     65535;
     prefs.gui_marked_fg.red          =     65535;
     prefs.gui_marked_fg.green        =     65535;
     prefs.gui_marked_fg.blue         =     65535;
     prefs.gui_marked_fg.red          =     65535;
     prefs.gui_marked_fg.green        =     65535;
     prefs.gui_marked_fg.blue         =     65535;
-    prefs.gui_marked_bg.pixel        =         0;
     prefs.gui_marked_bg.red          =         0;
     prefs.gui_marked_bg.green        =      8224;
     prefs.gui_marked_bg.blue         =     10794;
     prefs.gui_marked_bg.red          =         0;
     prefs.gui_marked_bg.green        =      8224;
     prefs.gui_marked_bg.blue         =     10794;
-    prefs.gui_ignored_fg.pixel       =     32767;
     prefs.gui_ignored_fg.red         =     32767;
     prefs.gui_ignored_fg.green       =     32767;
     prefs.gui_ignored_fg.blue        =     32767;
     prefs.gui_ignored_fg.red         =     32767;
     prefs.gui_ignored_fg.green       =     32767;
     prefs.gui_ignored_fg.blue        =     32767;
-    prefs.gui_ignored_bg.pixel       =     65535;
     prefs.gui_ignored_bg.red         =     65535;
     prefs.gui_ignored_bg.green       =     65535;
     prefs.gui_ignored_bg.blue        =     65535;
     prefs.gui_ignored_bg.red         =     65535;
     prefs.gui_ignored_bg.green       =     65535;
     prefs.gui_ignored_bg.blue        =     65535;
-    if (prefs.gui_colorized_fg) g_free(prefs.gui_colorized_fg);
+    g_free(prefs.gui_colorized_fg);
     prefs.gui_colorized_fg           = g_strdup("000000,000000,000000,000000,000000,000000,000000,000000,000000,000000");
     prefs.gui_colorized_fg           = g_strdup("000000,000000,000000,000000,000000,000000,000000,000000,000000,000000");
-    if (prefs.gui_colorized_bg) g_free(prefs.gui_colorized_bg);
+    g_free(prefs.gui_colorized_bg);
     prefs.gui_colorized_bg           = g_strdup("ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0");
     prefs.gui_colorized_bg           = g_strdup("ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0");
-    prefs.st_client_fg.pixel         =     0;
     prefs.st_client_fg.red           = 32767;
     prefs.st_client_fg.green         =     0;
     prefs.st_client_fg.blue          =     0;
     prefs.st_client_fg.red           = 32767;
     prefs.st_client_fg.green         =     0;
     prefs.st_client_fg.blue          =     0;
-    prefs.st_client_bg.pixel         =     0;
     prefs.st_client_bg.red           = 64507;
     prefs.st_client_bg.green         = 60909;
     prefs.st_client_bg.blue          = 60909;
     prefs.st_client_bg.red           = 64507;
     prefs.st_client_bg.green         = 60909;
     prefs.st_client_bg.blue          = 60909;
-    prefs.st_server_fg.pixel         =     0;
     prefs.st_server_fg.red           =     0;
     prefs.st_server_fg.green         =     0;
     prefs.st_server_fg.blue          = 32767;
     prefs.st_server_fg.red           =     0;
     prefs.st_server_fg.green         =     0;
     prefs.st_server_fg.blue          = 32767;
-    prefs.st_server_bg.pixel         =     0;
     prefs.st_server_bg.red           = 60909;
     prefs.st_server_bg.green         = 60909;
     prefs.st_server_bg.blue          = 64507;
     prefs.st_server_bg.red           = 60909;
     prefs.st_server_bg.green         = 60909;
     prefs.st_server_bg.blue          = 64507;
-    prefs.gui_text_valid.pixel         =     0; /* light green */
-    prefs.gui_text_valid.red           = 0xAFFF;
-    prefs.gui_text_valid.green         = 0xFFFF;
-    prefs.gui_text_valid.blue          = 0xAFFF;
-    prefs.gui_text_invalid.pixel     =     0;  /* light red */
-    prefs.gui_text_invalid.red       = 0xFFFF;
-    prefs.gui_text_invalid.green     = 0xAFFF;
-    prefs.gui_text_invalid.blue      = 0xAFFF;
-    prefs.gui_text_deprecated.pixel  =     0; /* light yellow */
-    prefs.gui_text_deprecated.red    = 0xFFFF;
-    prefs.gui_text_deprecated.green  = 0xFFFF;
-    prefs.gui_text_deprecated.blue   = 0xAFFF;
+
+    if (gui_theme_is_dark) {
+        // Green, red and yellow with HSV V = 84
+        prefs.gui_text_valid.red         = 0x0000; /* dark green */
+        prefs.gui_text_valid.green       = 0x66ff;
+        prefs.gui_text_valid.blue        = 0x0000;
+        prefs.gui_text_invalid.red       = 0x66FF; /* dark red */
+        prefs.gui_text_invalid.green     = 0x0000;
+        prefs.gui_text_invalid.blue      = 0x0000;
+        prefs.gui_text_deprecated.red    = 0x66FF; /* dark yellow / olive */
+        prefs.gui_text_deprecated.green  = 0x66FF;
+        prefs.gui_text_deprecated.blue   = 0x0000;
+    } else {
+        // Green, red and yellow with HSV V = 20
+        prefs.gui_text_valid.red         = 0xAFFF; /* light green */
+        prefs.gui_text_valid.green       = 0xFFFF;
+        prefs.gui_text_valid.blue        = 0xAFFF;
+        prefs.gui_text_invalid.red       = 0xFFFF; /* light red */
+        prefs.gui_text_invalid.green     = 0xAFFF;
+        prefs.gui_text_invalid.blue      = 0xAFFF;
+        prefs.gui_text_deprecated.red    = 0xFFFF; /* light yellow */
+        prefs.gui_text_deprecated.green  = 0xFFFF;
+        prefs.gui_text_deprecated.blue   = 0xAFFF;
+    }
+
     prefs.gui_geometry_save_position = TRUE;
     prefs.gui_geometry_save_size     = TRUE;
     prefs.gui_geometry_save_maximized= TRUE;
     prefs.gui_geometry_save_position = TRUE;
     prefs.gui_geometry_save_size     = TRUE;
     prefs.gui_geometry_save_maximized= TRUE;
-    prefs.gui_macosx_style           = TRUE;
     prefs.gui_console_open           = console_open_never;
     prefs.gui_fileopen_style         = FO_STYLE_LAST_OPENED;
     prefs.gui_recent_df_entries_max  = 10;
     prefs.gui_recent_files_count_max = 10;
     prefs.gui_console_open           = console_open_never;
     prefs.gui_fileopen_style         = FO_STYLE_LAST_OPENED;
     prefs.gui_recent_df_entries_max  = 10;
     prefs.gui_recent_files_count_max = 10;
-    if (prefs.gui_fileopen_dir) g_free(prefs.gui_fileopen_dir);
+    g_free(prefs.gui_fileopen_dir);
     prefs.gui_fileopen_dir           = g_strdup(get_persdatafile_dir());
     prefs.gui_fileopen_preview       = 3;
     prefs.gui_ask_unsaved            = TRUE;
     prefs.gui_fileopen_dir           = g_strdup(get_persdatafile_dir());
     prefs.gui_fileopen_preview       = 3;
     prefs.gui_ask_unsaved            = TRUE;
@@ -3040,19 +4032,15 @@ pre_init_prefs(void)
     prefs.gui_update_enabled         = TRUE;
     prefs.gui_update_channel         = UPDATE_CHANNEL_STABLE;
     prefs.gui_update_interval        = 60*60*24; /* Seconds */
     prefs.gui_update_enabled         = TRUE;
     prefs.gui_update_channel         = UPDATE_CHANNEL_STABLE;
     prefs.gui_update_interval        = 60*60*24; /* Seconds */
-    if (prefs.gui_webbrowser) g_free(prefs.gui_webbrowser);
-#ifdef HTML_VIEWER
-    prefs.gui_webbrowser             = g_strdup(HTML_VIEWER " %s");
-#else
+    g_free(prefs.gui_webbrowser);
     prefs.gui_webbrowser             = g_strdup("");
     prefs.gui_webbrowser             = g_strdup("");
-#endif
-    if (prefs.gui_window_title) g_free(prefs.gui_window_title);
+    g_free(prefs.gui_window_title);
     prefs.gui_window_title           = g_strdup("");
     prefs.gui_window_title           = g_strdup("");
-    if (prefs.gui_start_title) g_free(prefs.gui_start_title);
+    g_free(prefs.gui_prepend_window_title);
+    prefs.gui_prepend_window_title   = g_strdup("");
+    g_free(prefs.gui_start_title);
     prefs.gui_start_title            = g_strdup("The World's Most Popular Network Protocol Analyzer");
     prefs.gui_version_placement      = version_both;
     prefs.gui_start_title            = g_strdup("The World's Most Popular Network Protocol Analyzer");
     prefs.gui_version_placement      = version_both;
-    prefs.gui_auto_scroll_on_expand  = FALSE;
-    prefs.gui_auto_scroll_percentage = 0;
     prefs.gui_layout_type            = layout_type_5;
     prefs.gui_layout_content_1       = layout_pane_content_plist;
     prefs.gui_layout_content_2       = layout_pane_content_pdetails;
     prefs.gui_layout_type            = layout_type_5;
     prefs.gui_layout_content_1       = layout_pane_content_plist;
     prefs.gui_layout_content_2       = layout_pane_content_pdetails;
@@ -3061,8 +4049,16 @@ pre_init_prefs(void)
     prefs.gui_packet_list_elide_mode = ELIDE_RIGHT;
     prefs.gui_packet_list_show_related = TRUE;
     prefs.gui_packet_list_show_minimap = TRUE;
     prefs.gui_packet_list_elide_mode = ELIDE_RIGHT;
     prefs.gui_packet_list_show_related = TRUE;
     prefs.gui_packet_list_show_minimap = TRUE;
+    g_free (prefs.gui_interfaces_hide_types);
+    prefs.gui_interfaces_hide_types = g_strdup("");
+    prefs.gui_interfaces_show_hidden = FALSE;
+#ifdef HAVE_PCAP_REMOTE
+    prefs.gui_interfaces_remote_display = TRUE;
+#endif
 
     prefs.gui_qt_packet_list_separator = FALSE;
 
     prefs.gui_qt_packet_list_separator = FALSE;
+    prefs.gui_qt_show_selected_packet = FALSE;
+    prefs.gui_qt_show_file_load_time = FALSE;
 
     if (prefs.col_list) {
         free_col_info(prefs.col_list);
 
     if (prefs.col_list) {
         free_col_info(prefs.col_list);
@@ -3088,6 +4084,7 @@ pre_init_prefs(void)
     prefs.capture_pcap_ng               = FALSE;
 #endif
     prefs.capture_real_time             = TRUE;
     prefs.capture_pcap_ng               = FALSE;
 #endif
     prefs.capture_real_time             = TRUE;
+    prefs.capture_no_extcap             = FALSE;
     prefs.capture_auto_scroll           = TRUE;
     prefs.capture_show_info             = FALSE;
 
     prefs.capture_auto_scroll           = TRUE;
     prefs.capture_show_info             = FALSE;
 
@@ -3104,7 +4101,6 @@ pre_init_prefs(void)
 
 /* set the default values for the tap/statistics dialog box */
     prefs.tap_update_interval    = TAP_UPDATE_DEFAULT_INTERVAL;
 
 /* set the default values for the tap/statistics dialog box */
     prefs.tap_update_interval    = TAP_UPDATE_DEFAULT_INTERVAL;
-    prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
     prefs.st_enable_burstinfo = TRUE;
     prefs.st_burst_showcount = FALSE;
     prefs.st_burst_resolution = ST_DEF_BURSTRES;
     prefs.st_enable_burstinfo = TRUE;
     prefs.st_burst_showcount = FALSE;
     prefs.st_burst_resolution = ST_DEF_BURSTRES;
@@ -3122,14 +4118,29 @@ pre_init_prefs(void)
 /*
  * Reset a single dissector preference.
  */
 /*
  * Reset a single dissector preference.
  */
-static void
+void
 reset_pref(pref_t *pref)
 {
 reset_pref(pref_t *pref)
 {
+    int type;
     if (!pref) return;
 
     if (!pref) return;
 
-    switch (pref->type) {
+    type = pref->type;
+
+    /*
+     * This preference is no longer supported; it's not a
+     * real preference, so we don't reset it (i.e., we
+     * treat it as if it weren't found in the list of
+     * preferences, and we weren't called in the first place).
+     */
+    if (IS_PREF_OBSOLETE(type))
+        return;
+    else
+        RESET_PREF_OBSOLETE(type);
+
+    switch (type) {
 
     case PREF_UINT:
 
     case PREF_UINT:
+    case PREF_DECODE_AS_UINT:
         *pref->varp.uint = pref->default_val.uint;
         break;
 
         *pref->varp.uint = pref->default_val.uint;
         break;
 
@@ -3149,14 +4160,16 @@ reset_pref(pref_t *pref)
         break;
 
     case PREF_STRING:
         break;
 
     case PREF_STRING:
-    case PREF_FILENAME:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
     case PREF_DIRNAME:
         reset_string_like_preference(pref);
         break;
 
     case PREF_RANGE:
     case PREF_DIRNAME:
         reset_string_like_preference(pref);
         break;
 
     case PREF_RANGE:
-        g_free(*pref->varp.range);
-        *pref->varp.range = range_copy(pref->default_val.range);
+    case PREF_DECODE_AS_RANGE:
+        wmem_free(wmem_epan_scope(), *pref->varp.range);
+        *pref->varp.range = range_copy(wmem_epan_scope(), pref->default_val.range);
         break;
 
     case PREF_STATIC_TEXT:
         break;
 
     case PREF_STATIC_TEXT:
@@ -3171,15 +4184,6 @@ reset_pref(pref_t *pref)
     case PREF_CUSTOM:
         pref->custom_cbs.reset_cb(pref);
         break;
     case PREF_CUSTOM:
         pref->custom_cbs.reset_cb(pref);
         break;
-
-    case PREF_OBSOLETE:
-        /*
-         * This preference is no longer supported; it's not a
-         * real preference, so we don't reset it (i.e., we
-         * treat it as if it weren't found in the list of
-         * preferences, and we weren't called in the first place).
-         */
-        break;
     }
 }
 
     }
 }
 
@@ -3225,12 +4229,6 @@ prefs_reset(void)
      */
     oids_cleanup();
 
      */
     oids_cleanup();
 
-    /*
-     * Free the filter expression list.
-     */
-    filter_expression_free(*pfilter_expression_head);
-    *pfilter_expression_head = NULL;
-
     /*
      * Reset the non-dissector preferences.
      */
     /*
      * Reset the non-dissector preferences.
      */
@@ -3244,19 +4242,10 @@ prefs_reset(void)
 
 /* Read the preferences file, fill in "prefs", and return a pointer to it.
 
 
 /* Read the preferences file, fill in "prefs", and return a pointer to it.
 
-   If we got an error (other than "it doesn't exist") trying to read
-   the global preferences file, stuff the errno into "*gpf_errno_return"
-   and a pointer to the path of the file into "*gpf_path_return", and
-   return NULL.
-
-   If we got an error (other than "it doesn't exist") trying to read
-   the user's preferences file, stuff the errno into "*pf_errno_return"
-   and a pointer to the path of the file into "*pf_path_return", and
-   return NULL. */
+   If we got an error (other than "it doesn't exist") we report it through
+   the UI. */
 e_prefs *
 e_prefs *
-read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
-           char **gpf_path_return, int *pf_errno_return,
-           int *pf_read_errno_return, char **pf_path_return)
+read_prefs(void)
 {
     int         err;
     char        *pf_path;
 {
     int         err;
     char        *pf_path;
@@ -3297,7 +4286,6 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
      * XXX - if it failed for a reason other than "it doesn't exist",
      * report the error.
      */
      * XXX - if it failed for a reason other than "it doesn't exist",
      * report the error.
      */
-    *gpf_path_return = NULL;
     if (pf != NULL) {
         /*
          * Start out the counters of "mgcp.{tcp,udp}.port" entries we've
     if (pf != NULL) {
         /*
          * Start out the counters of "mgcp.{tcp,udp}.port" entries we've
@@ -3309,21 +4297,19 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
         /* We succeeded in opening it; read it. */
         err = read_prefs_file(gpf_path, pf, set_pref, NULL);
         if (err != 0) {
         /* We succeeded in opening it; read it. */
         err = read_prefs_file(gpf_path, pf, set_pref, NULL);
         if (err != 0) {
-            /* We had an error reading the file; return the errno and the
-               pathname, so our caller can report the error. */
-            *gpf_errno_return = 0;
-            *gpf_read_errno_return = err;
-            *gpf_path_return = gpf_path;
+            /* We had an error reading the file; report it. */
+            report_warning("Error reading global preferences file \"%s\": %s.",
+                           gpf_path, g_strerror(err));
         }
         fclose(pf);
     } else {
         /* We failed to open it.  If we failed for some reason other than
         }
         fclose(pf);
     } else {
         /* We failed to open it.  If we failed for some reason other than
-           "it doesn't exist", return the errno and the pathname, so our
-           caller can report the error. */
+           "it doesn't exist", report the error. */
         if (errno != ENOENT) {
         if (errno != ENOENT) {
-            *gpf_errno_return = errno;
-            *gpf_read_errno_return = 0;
-            *gpf_path_return = gpf_path;
+            if (errno != 0) {
+                report_warning("Can't open global preferences file \"%s\": %s.",
+                               gpf_path, g_strerror(errno));
+            }
         }
     }
 
         }
     }
 
@@ -3331,7 +4317,6 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
     pf_path = get_persconffile_path(PF_NAME, TRUE);
 
     /* Read the user's preferences file, if it exists. */
     pf_path = get_persconffile_path(PF_NAME, TRUE);
 
     /* Read the user's preferences file, if it exists. */
-    *pf_path_return = NULL;
     if ((pf = ws_fopen(pf_path, "r")) != NULL) {
         /*
          * Start out the counters of "mgcp.{tcp,udp}.port" entries we've
     if ((pf = ws_fopen(pf_path, "r")) != NULL) {
         /*
          * Start out the counters of "mgcp.{tcp,udp}.port" entries we've
@@ -3343,11 +4328,9 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
         /* We succeeded in opening it; read it. */
         err = read_prefs_file(pf_path, pf, set_pref, NULL);
         if (err != 0) {
         /* We succeeded in opening it; read it. */
         err = read_prefs_file(pf_path, pf, set_pref, NULL);
         if (err != 0) {
-            /* We had an error reading the file; return the errno and the
-               pathname, so our caller can report the error. */
-            *pf_errno_return = 0;
-            *pf_read_errno_return = err;
-            *pf_path_return = pf_path;
+            /* We had an error reading the file; report it. */
+            report_warning("Error reading your preferences file \"%s\": %s.",
+                           pf_path, g_strerror(err));
         } else
             g_free(pf_path);
         fclose(pf);
         } else
             g_free(pf_path);
         fclose(pf);
@@ -3356,9 +4339,8 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
            "it doesn't exist", return the errno and the pathname, so our
            caller can report the error. */
         if (errno != ENOENT) {
            "it doesn't exist", return the errno and the pathname, so our
            caller can report the error. */
         if (errno != ENOENT) {
-            *pf_errno_return = errno;
-            *pf_read_errno_return = 0;
-            *pf_path_return = pf_path;
+            report_warning("Can't open your preferences file \"%s\": %s.",
+                           pf_path, g_strerror(errno));
         } else
             g_free(pf_path);
     }
         } else
             g_free(pf_path);
     }
@@ -3401,12 +4383,12 @@ read_prefs_file(const char *pf_path, FILE *pf,
     }
     rewind(pf);
 
     }
     rewind(pf);
 
-    while ((got_c = getc(pf)) != EOF) {
+    while ((got_c = ws_getc_unlocked(pf)) != EOF) {
         if (got_c == '\r') {
             /* Treat CR-LF at the end of a line like LF, so that if we're reading
              * a Windows-format file on UN*X, we handle it the same way we'd handle
              * a UN*X-format file. */
         if (got_c == '\r') {
             /* Treat CR-LF at the end of a line like LF, so that if we're reading
              * a Windows-format file on UN*X, we handle it the same way we'd handle
              * a UN*X-format file. */
-            got_c = getc(pf);
+            got_c = ws_getc_unlocked(pf);
             if (got_c == EOF)
                 break;
             if (got_c != '\n') {
             if (got_c == EOF)
                 break;
             if (got_c != '\n') {
@@ -3432,7 +4414,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
                                  * If the pref has a trailing comma, eliminate it.
                                  */
                                 cur_val->str[cur_val->len-1] = '\0';
                                  * If the pref has a trailing comma, eliminate it.
                                  */
                                 cur_val->str[cur_val->len-1] = '\0';
-                                g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint);
+                                ws_g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint);
                             }
                         }
                         /* Call the routine to set the preference; it will parse
                             }
                         }
                         /* Call the routine to set the preference; it will parse
@@ -3448,7 +4430,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
                             break;
 
                         case PREFS_SET_SYNTAX_ERR:
                             break;
 
                         case PREFS_SET_SYNTAX_ERR:
-                            g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
+                            ws_g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
                                        cur_var->str, pline, pf_path, hint);
                             break;
 
                                        cur_var->str, pline, pf_path, hint);
                             break;
 
@@ -3458,7 +4440,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
                              * on non-Win32 platforms.
                              */
                             if (strcmp(cur_var->str, "print.command") != 0)
                              * on non-Win32 platforms.
                              */
                             if (strcmp(cur_var->str, "print.command") != 0)
-                                g_warning ("No such preference \"%s\" at line %d of\n%s %s",
+                                ws_g_warning ("No such preference \"%s\" at line %d of\n%s %s",
                                            cur_var->str, pline, pf_path, hint);
                             prefs.unknown_prefs = TRUE;
                             break;
                                            cur_var->str, pline, pf_path, hint);
                             prefs.unknown_prefs = TRUE;
                             break;
@@ -3471,13 +4453,13 @@ read_prefs_file(const char *pf_path, FILE *pf,
                                    The prefs in question need to be listed in the console window so that the
                                    user can make an informed choice.
                                 */
                                    The prefs in question need to be listed in the console window so that the
                                    user can make an informed choice.
                                 */
-                                g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
+                                ws_g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
                                            cur_var->str, pline, pf_path, hint);
                             prefs.unknown_prefs = TRUE;
                             break;
                         }
                     } else {
                                            cur_var->str, pline, pf_path, hint);
                             prefs.unknown_prefs = TRUE;
                             break;
                         }
                     } else {
-                        g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
+                        ws_g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
                     }
                 }
                 state      = IN_VAR;
                     }
                 }
                 state      = IN_VAR;
@@ -3490,7 +4472,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
             } else if (got_c == '#') {
                 state = IN_SKIP;
             } else {
             } else if (got_c == '#') {
                 state = IN_SKIP;
             } else {
-                g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
+                ws_g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
             }
             break;
         case IN_VAR:
             }
             break;
         case IN_VAR:
@@ -3535,12 +4517,12 @@ read_prefs_file(const char *pf_path, FILE *pf,
                 break;
 
             case PREFS_SET_SYNTAX_ERR:
                 break;
 
             case PREFS_SET_SYNTAX_ERR:
-                g_warning ("Syntax error in preference %s at line %d of\n%s %s",
+                ws_g_warning ("Syntax error in preference %s at line %d of\n%s %s",
                            cur_var->str, pline, pf_path, hint);
                 break;
 
             case PREFS_SET_NO_SUCH_PREF:
                            cur_var->str, pline, pf_path, hint);
                 break;
 
             case PREFS_SET_NO_SUCH_PREF:
-                g_warning ("No such preference \"%s\" at line %d of\n%s %s",
+                ws_g_warning ("No such preference \"%s\" at line %d of\n%s %s",
                            cur_var->str, pline, pf_path, hint);
                 prefs.unknown_prefs = TRUE;
                 break;
                            cur_var->str, pline, pf_path, hint);
                 prefs.unknown_prefs = TRUE;
                 break;
@@ -3550,7 +4532,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
                 break;
             }
         } else {
                 break;
             }
         } else {
-            g_warning ("Incomplete preference at line %d of\n%s %s",
+            ws_g_warning("Incomplete preference at line %d of\n%s %s",
                        pline, pf_path, hint);
         }
     }
                        pline, pf_path, hint);
         }
     }
@@ -3569,10 +4551,9 @@ read_prefs_file(const char *pf_path, FILE *pf,
  * a valid uat entry.
  */
 static gboolean
  * a valid uat entry.
  */
 static gboolean
-prefs_set_uat_pref(char *uat_entry) {
+prefs_set_uat_pref(char *uat_entry, char **errmsg) {
     gchar *p, *colonp;
     uat_t *uat;
     gchar *p, *colonp;
     uat_t *uat;
-    gchar *err = NULL;
     gboolean ret;
 
     colonp = strchr(uat_entry, ':');
     gboolean ret;
 
     colonp = strchr(uat_entry, ':');
@@ -3602,11 +4583,11 @@ prefs_set_uat_pref(char *uat_entry) {
     uat = uat_find(uat_entry);
     *colonp = ':';
     if (uat == NULL) {
     uat = uat_find(uat_entry);
     *colonp = ':';
     if (uat == NULL) {
+        *errmsg = g_strdup("Unknown preference");
         return FALSE;
     }
 
         return FALSE;
     }
 
-    ret = uat_load_str(uat, p, &err);
-    g_free(err);
+    ret = uat_load_str(uat, p, errmsg);
     return ret;
 }
 
     return ret;
 }
 
@@ -3617,7 +4598,7 @@ prefs_set_uat_pref(char *uat_entry) {
  * in some fashion.
  */
 prefs_set_pref_e
  * in some fashion.
  */
 prefs_set_pref_e
-prefs_set_pref(char *prefarg)
+prefs_set_pref(char *prefarg, char **errmsg)
 {
     gchar *p, *colonp;
     prefs_set_pref_e ret;
 {
     gchar *p, *colonp;
     prefs_set_pref_e ret;
@@ -3632,6 +4613,8 @@ prefs_set_pref(char *prefarg)
     mgcp_tcp_port_count = -1;
     mgcp_udp_port_count = -1;
 
     mgcp_tcp_port_count = -1;
     mgcp_udp_port_count = -1;
 
+    *errmsg = NULL;
+
     colonp = strchr(prefarg, ':');
     if (colonp == NULL)
         return PREFS_SET_SYNTAX_ERR;
     colonp = strchr(prefarg, ':');
     if (colonp == NULL)
         return PREFS_SET_SYNTAX_ERR;
@@ -3658,10 +4641,72 @@ prefs_set_pref(char *prefarg)
     if (strcmp(prefarg, "uat")) {
         ret = set_pref(prefarg, p, NULL, TRUE);
     } else {
     if (strcmp(prefarg, "uat")) {
         ret = set_pref(prefarg, p, NULL, TRUE);
     } else {
-        ret = prefs_set_uat_pref(p) ? PREFS_SET_OK : PREFS_SET_SYNTAX_ERR;
+        ret = prefs_set_uat_pref(p, errmsg) ? PREFS_SET_OK : PREFS_SET_SYNTAX_ERR;
+    }
+    *colonp = ':';    /* put the colon back */
+    return ret;
+}
+
+guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source)
+{
+    switch (source)
+    {
+    case pref_default:
+        return pref->default_val.uint;
+        break;
+    case pref_stashed:
+        return pref->stashed_val.uint;
+        break;
+    case pref_current:
+        return *pref->varp.uint;
+        break;
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    return 0;
+}
+
+guint prefs_get_uint_value(const char *module_name, const char* pref_name)
+{
+    return prefs_get_uint_value_real(prefs_find_preference(prefs_find_module(module_name), pref_name), pref_current);
+}
+
+unsigned int prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source)
+{
+    unsigned int changed = 0;
+    switch (source)
+    {
+    case pref_default:
+        if (pref->default_val.uint != value) {
+            pref->default_val.uint = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    case pref_stashed:
+        if (pref->stashed_val.uint != value) {
+            pref->stashed_val.uint = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    case pref_current:
+        if (*pref->varp.uint != value) {
+            *pref->varp.uint = value;
+            changed = prefs_get_effect_flags(pref);
+        }
+        break;
+    default:
+        g_assert_not_reached();
+        break;
     }
     }
-    *colonp = ':';    /* put the colon back */
-    return ret;
+
+    return changed;
+}
+
+guint prefs_get_uint_base(pref_t *pref)
+{
+    return pref->info.base;
 }
 
 /*
 }
 
 /*
@@ -3810,10 +4855,22 @@ prefs_capture_options_dialog_column_is_visible(const gchar *column)
     return FALSE;
 }
 
     return FALSE;
 }
 
+gboolean
+prefs_has_layout_pane_content (layout_pane_content_e layout_pane_content)
+{
+    return ((prefs.gui_layout_content_1 == layout_pane_content) ||
+            (prefs.gui_layout_content_2 == layout_pane_content) ||
+            (prefs.gui_layout_content_3 == layout_pane_content));
+}
+
 #define PRS_GUI_FILTER_LABEL             "gui.filter_expressions.label"
 #define PRS_GUI_FILTER_EXPR              "gui.filter_expressions.expr"
 #define PRS_GUI_FILTER_ENABLED           "gui.filter_expressions.enabled"
 
 #define PRS_GUI_FILTER_LABEL             "gui.filter_expressions.label"
 #define PRS_GUI_FILTER_EXPR              "gui.filter_expressions.expr"
 #define PRS_GUI_FILTER_ENABLED           "gui.filter_expressions.enabled"
 
+/*
+ * Extract the red, green, and blue components of a 24-bit RGB value
+ * and convert them from [0,255] to [0,65535].
+ */
 #define RED_COMPONENT(x)   (guint16) (((((x) >> 16) & 0xff) * 65535 / 255))
 #define GREEN_COMPONENT(x) (guint16) (((((x) >>  8) & 0xff) * 65535 / 255))
 #define BLUE_COMPONENT(x)  (guint16) ( (((x)        & 0xff) * 65535 / 255))
 #define RED_COMPONENT(x)   (guint16) (((((x) >> 16) & 0xff) * 65535 / 255))
 #define GREEN_COMPONENT(x) (guint16) (((((x) >>  8) & 0xff) * 65535 / 255))
 #define BLUE_COMPONENT(x)  (guint16) ( (((x)        & 0xff) * 65535 / 255))
@@ -3839,11 +4896,15 @@ string_to_name_resolve(const char *string, e_addr_resolve *name_resolve)
             name_resolve->transport_name = TRUE;
             break;
         case 'C':
             name_resolve->transport_name = TRUE;
             break;
         case 'C':
-            name_resolve->concurrent_dns = TRUE;
+            /* DEPRECATED */
+            /* name_resolve->concurrent_dns */
             break;
         case 'd':
             name_resolve->dns_pkt_addr_resolution = TRUE;
             break;
             break;
         case 'd':
             name_resolve->dns_pkt_addr_resolution = TRUE;
             break;
+        case 'v':
+            name_resolve->vlan_name = TRUE;
+            break;
         default:
             /*
              * Unrecognized letter.
         default:
             /*
              * Unrecognized letter.
@@ -3854,32 +4915,10 @@ string_to_name_resolve(const char *string, e_addr_resolve *name_resolve)
     return '\0';
 }
 
     return '\0';
 }
 
-
 static void
 try_convert_to_custom_column(gpointer *el_data)
 {
 static void
 try_convert_to_custom_column(gpointer *el_data)
 {
-    /* Array of columns that have been migrated to custom columns */
-    struct {
-        gint el;
-        const gchar *col_expr;
-    } migrated_columns[] = {
-        { COL_COS_VALUE, "vlan.priority" },
-        { COL_CIRCUIT_ID, "iax2.call" },
-        { COL_BSSGP_TLLI, "bssgp.tlli" },
-        { COL_HPUX_SUBSYS, "nettl.subsys" },
-        { COL_HPUX_DEVID, "nettl.devid" },
-        { COL_FR_DLCI, "fr.dlci" },
-        { COL_REL_CONV_TIME, "tcp.time_relative" },
-        { COL_DELTA_CONV_TIME, "tcp.time_delta" },
-        { COL_OXID, "fc.ox_id" },
-        { COL_RXID, "fc.rx_id" },
-        { COL_SRCIDX, "mdshdr.srcidx" },
-        { COL_DSTIDX, "mdshdr.dstidx" },
-        { COL_DCE_CTX, "dcerpc.cn_ctx_id" }
-    };
-
     guint haystack_idx;
     guint haystack_idx;
-    const gchar *haystack_fmt;
 
     gchar **fmt = (gchar **) el_data;
 
 
     gchar **fmt = (gchar **) el_data;
 
@@ -3887,8 +4926,7 @@ try_convert_to_custom_column(gpointer *el_data)
          haystack_idx < G_N_ELEMENTS(migrated_columns);
          ++haystack_idx) {
 
          haystack_idx < G_N_ELEMENTS(migrated_columns);
          ++haystack_idx) {
 
-        haystack_fmt = col_format_to_string(migrated_columns[haystack_idx].el);
-        if (strcmp(haystack_fmt, *fmt) == 0) {
+        if (strcmp(migrated_columns[haystack_idx].col_fmt, *fmt) == 0) {
             gchar *cust_col = g_strdup_printf("%%Cus:%s:0",
                                 migrated_columns[haystack_idx].col_expr);
 
             gchar *cust_col = g_strdup_printf("%%Cus:%s:0",
                                 migrated_columns[haystack_idx].col_expr);
 
@@ -3925,6 +4963,8 @@ deprecated_heur_dissector_pref(gchar *pref_name, const gchar *value)
         {"gvsp.enable_heuristic", "gvsp_udp", 0},
         {"hdcp2.enable", "hdcp2_tcp", 0},
         {"hislip.enable_heuristic", "hislip_tcp", 0},
         {"gvsp.enable_heuristic", "gvsp_udp", 0},
         {"hdcp2.enable", "hdcp2_tcp", 0},
         {"hislip.enable_heuristic", "hislip_tcp", 0},
+        {"infiniband.dissect_eoib", "mellanox_eoib", 1},
+        {"infiniband.identify_payload", "eth_over_ib", 0},
         {"jxta.udp.heuristic", "jxta_udp", 0},
         {"jxta.tcp.heuristic", "jxta_tcp", 0},
         {"jxta.sctp.heuristic", "jxta_sctp", 0},
         {"jxta.udp.heuristic", "jxta_udp", 0},
         {"jxta.tcp.heuristic", "jxta_tcp", 0},
         {"jxta.sctp.heuristic", "jxta_sctp", 0},
@@ -3970,6 +5010,295 @@ deprecated_heur_dissector_pref(gchar *pref_name, const gchar *value)
     return FALSE;
 }
 
     return FALSE;
 }
 
+static gboolean
+deprecated_enable_dissector_pref(gchar *pref_name, const gchar *value)
+{
+    struct dissector_pref_name
+    {
+        const char* pref_name;
+        const char* short_name;
+    };
+
+    struct dissector_pref_name dissector_prefs[] = {
+        {"transum.tsumenabled", "TRANSUM"},
+        {"snort.enable_snort_dissector", "Snort"},
+        {"prp.enable", "PRP"},
+    };
+
+    unsigned int i;
+    int proto_id;
+
+    for (i = 0; i < sizeof(dissector_prefs)/sizeof(struct dissector_pref_name); i++)
+    {
+        if (strcmp(pref_name, dissector_prefs[i].pref_name) == 0)
+        {
+            proto_id = proto_get_id_by_short_name(dissector_prefs[i].short_name);
+            if (proto_id >= 0)
+                proto_set_decoding(proto_id, ((g_ascii_strcasecmp(value, "true") == 0) ? TRUE : FALSE));
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+static gboolean
+deprecated_port_pref(gchar *pref_name, const gchar *value)
+{
+    struct port_pref_name
+    {
+        const char* pref_name;
+        const char* module_name;
+        const char* table_name;
+        guint base;
+    };
+
+    struct obsolete_pref_name
+    {
+        const char* pref_name;
+    };
+
+    /* For now this is only supporting TCP/UDP port dissector preferences
+       which are assumed to be decimal */
+    struct port_pref_name port_prefs[] = {
+        /* TCP */
+        {"cmp.tcp_alternate_port", "CMP", "tcp.port", 10},
+        {"h248.tcp_port", "H248", "tcp.port", 10},
+        {"cops.tcp.cops_port", "COPS", "tcp.port", 10},
+        {"dhcpfo.tcp_port", "DHCPFO", "tcp.port", 10},
+        {"enttec.tcp_port", "ENTTEC", "tcp.port", 10},
+        {"forces.tcp_alternate_port", "ForCES", "tcp.port", 10},
+        {"ged125.tcp_port", "GED125", "tcp.port", 10},
+        {"hpfeeds.dissector_port", "HPFEEDS", "tcp.port", 10},
+        {"lsc.port", "LSC", "tcp.port", 10},
+        {"megaco.tcp.txt_port", "MEGACO", "tcp.port", 10},
+        {"netsync.tcp_port", "Netsync", "tcp.port", 10},
+        {"osi.tpkt_port", "OSI", "tcp.port", 10},
+        {"rsync.tcp_port", "RSYNC", "tcp.port", 10},
+        {"sametime.tcp_port", "SAMETIME", "tcp.port", 10},
+        {"sigcomp.tcp.port2", "SIGCOMP", "tcp.port", 10},
+        {"synphasor.tcp_port", "SYNCHROPHASOR", "tcp.port", 10},
+        {"tipc.alternate_port", "TIPC", "tcp.port", 10},
+        {"vnc.alternate_port", "VNC", "tcp.port", 10},
+        {"scop.port", "SCoP", "tcp.port", 10},
+        {"scop.port_secure", "SCoP", "tcp.port", 10},
+        /* UDP */
+        {"h248.udp_port", "H248", "udp.port", 10},
+        {"actrace.udp_port", "ACtrace", "udp.port", 10},
+        {"brp.port", "BRP", "udp.port", 10},
+        {"bvlc.additional_udp_port", "BVLC", "udp.port", 10},
+        {"capwap.udp.port.control", "CAPWAP-CONTROL", "udp.port", 10},
+        {"capwap.udp.port.data", "CAPWAP-CONTROL", "udp.port", 10},
+        {"coap.udp_port", "CoAP", "udp.port", 10},
+        {"enttec.udp_port", "ENTTEC", "udp.port", 10},
+        {"forces.udp_alternate_port", "ForCES", "udp.port", 10},
+        {"ldss.udp_port", "LDSS", "udp.port", 10},
+        {"lmp.udp_port", "LMP", "udp.port", 10},
+        {"ltp.port", "LTP", "udp.port", 10},
+        {"lwres.udp.lwres_port", "LWRES", "udp.port", 10},
+        {"megaco.udp.txt_port", "MEGACO", "udp.port", 10},
+        {"pgm.udp.encap_ucast_port", "PGM", "udp.port", 10},
+        {"pgm.udp.encap_mcast_port", "PGM", "udp.port", 10},
+        {"quic.udp.quic.port", "QUIC", "udp.port", 10},
+        {"quic.udp.quics.port", "QUIC", "udp.port", 10},
+        {"radius.alternate_port", "RADIUS", "udp.port", 10},
+        {"rdt.default_udp_port", "RDT", "udp.port", 10},
+        {"alc.default.udp_port", "ALC", "udp.port", 10},
+        {"sigcomp.udp.port2", "SIGCOMP", "udp.port", 10},
+        {"synphasor.udp_port", "SYNCHROPHASOR", "udp.port", 10},
+        {"tdmop.udpport", "TDMoP", "udp.port", 10},
+        {"uaudp.port1", "UAUDP", "udp.port", 10},
+        {"uaudp.port2", "UAUDP", "udp.port", 10},
+        {"uaudp.port3", "UAUDP", "udp.port", 10},
+        {"uaudp.port4", "UAUDP", "udp.port", 10},
+        {"uhd.dissector_port", "UHD", "udp.port", 10},
+        {"vrt.dissector_port", "VITA 49", "udp.port", 10},
+        {"vuze-dht.udp_port", "Vuze-DHT", "udp.port", 10},
+        {"wimaxasncp.udp.wimax_port", "WiMAX ASN CP", "udp.port", 10},
+    };
+
+    struct port_pref_name port_range_prefs[] = {
+        /* TCP */
+        {"couchbase.tcp.ports", "Couchbase", "tcp.port", 10},
+        {"gsm_ipa.tcp_ports", "GSM over IP", "tcp.port", 10},
+        {"kafka.tcp.ports", "Kafka", "tcp.port", 10},
+        {"kt.tcp.ports", "Kyoto Tycoon", "tcp.port", 10},
+        {"memcache.tcp.ports", "MEMCACHE", "tcp.port", 10},
+        {"mrcpv2.tcp.port_range", "MRCPv2", "tcp.port", 10},
+        {"rtsp.tcp.port_range", "RTSP", "tcp.port", 10},
+        {"sip.tcp.ports", "SIP", "tcp.port", 10},
+        {"tds.tcp_ports", "TDS", "tcp.port", 10},
+        {"uma.tcp.ports", "UMA", "tcp.port", 10},
+        /* UDP */
+        {"aruba_erm.udp.ports", "ARUBA_ERM", "udp.port", 10},
+        {"diameter.udp.ports", "DIAMETER", "udp.port", 10},
+        {"dmp.udp_ports", "DMP", "udp.port", 10},
+        {"dns.udp.ports", "DNS", "udp.port", 10},
+        {"gsm_ipa.udp_ports", "GSM over IP", "udp.port", 10},
+        {"hcrt.dissector_udp_port", "HCrt", "udp.port", 10},
+        {"memcache.udp.ports", "MEMCACHE", "udp.port", 10},
+        {"nb_rtpmux.udp_ports", "NB_RTPMUX", "udp.port", 10},
+        {"gprs-ns.udp.ports", "GPRS-NS", "udp.port", 10},
+        {"p_mul.udp_ports", "P_MUL", "udp.port", 10},
+        {"radius.ports", "RADIUS", "udp.port", 10},
+        {"sflow.ports", "sFlow", "udp.port", 10},
+        {"sscop.udp.ports", "SSCOP", "udp.port", 10},
+        {"tftp.udp_ports", "TFTP", "udp.port", 10},
+        {"tipc.udp.ports", "TIPC", "udp.port", 10},
+    };
+
+    /* These are subdissectors of TPKT/OSITP that used to have a
+       TCP port preference even though they were never
+       directly on TCP.  Convert them to use Decode As
+       with the TPKT dissector handle */
+    struct port_pref_name tpkt_subdissector_port_prefs[] = {
+        {"dap.tcp.port", "DAP", "tcp.port", 10},
+        {"disp.tcp.port", "DISP", "tcp.port", 10},
+        {"dop.tcp.port", "DOP", "tcp.port", 10},
+        {"dsp.tcp.port", "DSP", "tcp.port", 10},
+        {"p1.tcp.port", "P1", "tcp.port", 10},
+        {"p7.tcp.port", "P7", "tcp.port", 10},
+        {"rdp.tcp.port", "RDP", "tcp.port", 10},
+    };
+
+    /* These are obsolete preferences from the dissectors' view,
+       (typically because of a switch from a single value to a
+       range value) but the name of the preference conflicts
+       with the generated preference name from the dissector table.
+       Don't allow the obsolete preference through to be handled */
+    struct obsolete_pref_name obsolete_prefs[] = {
+        {"diameter.tcp.port"},
+        {"kafka.tcp.port"},
+        {"mrcpv2.tcp.port"},
+        {"rtsp.tcp.port"},
+        {"sip.tcp.port"},
+        {"t38.tcp.port"},
+    };
+
+    unsigned int i;
+    char     *p;
+    guint    uval;
+    dissector_table_t sub_dissectors;
+    dissector_handle_t handle, tpkt_handle;
+    module_t *module;
+    pref_t *pref;
+
+    for (i = 0; i < sizeof(port_prefs)/sizeof(struct port_pref_name); i++)
+    {
+        if (strcmp(pref_name, port_prefs[i].pref_name) == 0)
+        {
+            /* XXX - give an error if it doesn't fit in a guint? */
+            uval = (guint)strtoul(value, &p, port_prefs[i].base);
+            if (p == value || *p != '\0')
+                return FALSE;        /* number was bad */
+
+            module = prefs_find_module(port_prefs[i].module_name);
+            pref = prefs_find_preference(module, port_prefs[i].table_name);
+            if (pref != NULL)
+            {
+                module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+                *pref->varp.uint = uval;
+            }
+
+            /* If the value is zero, it wouldn't add to the Decode As tables */
+            if (uval != 0)
+            {
+                sub_dissectors = find_dissector_table(port_prefs[i].table_name);
+                if (sub_dissectors != NULL) {
+                    handle = dissector_table_get_dissector_handle(sub_dissectors, port_prefs[i].module_name);
+                    if (handle != NULL) {
+                        dissector_change_uint(port_prefs[i].table_name, uval, handle);
+                        decode_build_reset_list(port_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(uval), NULL, NULL);
+                    }
+                }
+            }
+
+            return TRUE;
+        }
+    }
+
+    for (i = 0; i < sizeof(port_range_prefs)/sizeof(struct port_pref_name); i++)
+    {
+        if (strcmp(pref_name, port_range_prefs[i].pref_name) == 0)
+        {
+            guint32 range_i, range_j;
+
+            sub_dissectors = find_dissector_table(port_range_prefs[i].table_name);
+            if (sub_dissectors != NULL) {
+                switch (dissector_table_get_type(sub_dissectors)) {
+                case FT_UINT8:
+                case FT_UINT16:
+                case FT_UINT24:
+                case FT_UINT32:
+                    break;
+
+                default:
+                    g_error("The dissector table %s (%s) is not an integer type - are you using a buggy plugin?", port_range_prefs[i].table_name, get_dissector_table_ui_name(port_range_prefs[i].table_name));
+                    g_assert_not_reached();
+                }
+
+                module = prefs_find_module(port_range_prefs[i].module_name);
+                pref = prefs_find_preference(module, port_range_prefs[i].table_name);
+                if (pref != NULL)
+                {
+                    if (!prefs_set_range_value_work(pref, value, TRUE, &module->prefs_changed_flags))
+                    {
+                        return FALSE;        /* number was bad */
+                    }
+
+                    handle = dissector_table_get_dissector_handle(sub_dissectors, port_range_prefs[i].module_name);
+                    if (handle != NULL) {
+
+                        for (range_i = 0; range_i < (*pref->varp.range)->nranges; range_i++) {
+                            for (range_j = (*pref->varp.range)->ranges[range_i].low; range_j < (*pref->varp.range)->ranges[range_i].high; range_j++) {
+                                dissector_change_uint(port_range_prefs[i].table_name, range_j, handle);
+                                decode_build_reset_list(port_range_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(range_j), NULL, NULL);
+                            }
+
+                            dissector_change_uint(port_range_prefs[i].table_name, (*pref->varp.range)->ranges[range_i].high, handle);
+                            decode_build_reset_list(port_range_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[range_i].high), NULL, NULL);
+                        }
+                    }
+                }
+            }
+
+            return TRUE;
+        }
+    }
+
+    for (i = 0; i < sizeof(tpkt_subdissector_port_prefs)/sizeof(struct port_pref_name); i++)
+    {
+        if (strcmp(pref_name, tpkt_subdissector_port_prefs[i].pref_name) == 0)
+        {
+            /* XXX - give an error if it doesn't fit in a guint? */
+            uval = (guint)strtoul(value, &p, tpkt_subdissector_port_prefs[i].base);
+            if (p == value || *p != '\0')
+                return FALSE;        /* number was bad */
+
+            /* If the value is 0 or 102 (default TPKT port), don't add to the Decode As tables */
+            if ((uval != 0) && (uval != 102))
+            {
+                tpkt_handle = find_dissector("tpkt");
+                if (tpkt_handle != NULL) {
+                    dissector_change_uint(tpkt_subdissector_port_prefs[i].table_name, uval, tpkt_handle);
+                }
+            }
+
+            return TRUE;
+        }
+    }
+
+    for (i = 0; i < sizeof(obsolete_prefs)/sizeof(struct obsolete_pref_name); i++)
+    {
+        if (strcmp(pref_name, obsolete_prefs[i].pref_name) == 0)
+        {
+            /* Just ignore the preference */
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
 static prefs_set_pref_e
 set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
          gboolean return_range_errors)
 static prefs_set_pref_e
 set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
          gboolean return_range_errors)
@@ -3983,16 +5312,20 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
     static gchar *filter_label = NULL;
     static gboolean filter_enabled = FALSE;
     gchar    *filter_expr = NULL;
     static gchar *filter_label = NULL;
     static gboolean filter_enabled = FALSE;
     gchar    *filter_expr = NULL;
-    module_t *module;
+    module_t *module, *containing_module;
     pref_t   *pref;
     pref_t   *pref;
+    int type;
 
 
+    //The PRS_GUI field names are here for backwards compatibility
+    //display filters have been converted to a UAT.
     if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) {
         filter_label = g_strdup(value);
     } else if (strcmp(pref_name, PRS_GUI_FILTER_ENABLED) == 0) {
         filter_enabled = (strcmp(value, "TRUE") == 0) ? TRUE : FALSE;
     } else if (strcmp(pref_name, PRS_GUI_FILTER_EXPR) == 0) {
         filter_expr = g_strdup(value);
     if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) {
         filter_label = g_strdup(value);
     } else if (strcmp(pref_name, PRS_GUI_FILTER_ENABLED) == 0) {
         filter_enabled = (strcmp(value, "TRUE") == 0) ? TRUE : FALSE;
     } else if (strcmp(pref_name, PRS_GUI_FILTER_EXPR) == 0) {
         filter_expr = g_strdup(value);
-        filter_expression_new(filter_label, filter_expr, filter_enabled);
+        /* Comments not supported for "old" preference style */
+        filter_expression_new(filter_label, filter_expr, "", filter_enabled);
         g_free(filter_label);
         g_free(filter_expr);
     } else if (strcmp(pref_name, "gui.version_in_start_page") == 0) {
         g_free(filter_label);
         g_free(filter_expr);
     } else if (strcmp(pref_name, "gui.version_in_start_page") == 0) {
@@ -4016,7 +5349,6 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
             gbl_resolv_flags.mac_name = TRUE;
             gbl_resolv_flags.network_name = TRUE;
             gbl_resolv_flags.transport_name = TRUE;
             gbl_resolv_flags.mac_name = TRUE;
             gbl_resolv_flags.network_name = TRUE;
             gbl_resolv_flags.transport_name = TRUE;
-            gbl_resolv_flags.concurrent_dns = TRUE;
         }
         else if (g_ascii_strcasecmp(value, "false") == 0) {
             disable_name_resolution();
         }
         else if (g_ascii_strcasecmp(value, "false") == 0) {
             disable_name_resolution();
@@ -4029,6 +5361,10 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
         }
     } else if (deprecated_heur_dissector_pref(pref_name, value)) {
          /* Handled within deprecated_heur_dissector_pref() if found */
         }
     } else if (deprecated_heur_dissector_pref(pref_name, value)) {
          /* Handled within deprecated_heur_dissector_pref() if found */
+    } else if (deprecated_enable_dissector_pref(pref_name, value)) {
+         /* Handled within deprecated_enable_dissector_pref() if found */
+    } else if (deprecated_port_pref(pref_name, value)) {
+         /* Handled within deprecated_port_pref() if found */
     } else {
         /* Handle deprecated "global" options that don't have a module
          * associated with them
     } else {
         /* Handle deprecated "global" options that don't have a module
          * associated with them
@@ -4101,7 +5437,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
                         return PREFS_SET_OBSOLETE;
                     }
                     if (module) {
                         return PREFS_SET_OBSOLETE;
                     }
                     if (module) {
-                        g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n"
+                        ws_g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n"
                                    "Save your preferences to make this change permanent.",
                                    pref_name, dotp+1, module->parent->name, pref_name, dotp+1);
                         prefs.unknown_prefs = TRUE;
                                    "Save your preferences to make this change permanent.",
                                    pref_name, dotp+1, module->parent->name, pref_name, dotp+1);
                         prefs.unknown_prefs = TRUE;
@@ -4113,7 +5449,10 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
             }
         }
 
             }
         }
 
-        pref = prefs_find_preference(module, dotp);
+        /* The pref is located in the module or a submodule.
+         * Assume module, then search for a submodule holding the pref. */
+        containing_module = module;
+        pref = prefs_find_preference_with_submodule(module, dotp, &containing_module);
 
         if (pref == NULL) {
             prefs.unknown_prefs = TRUE;
 
         if (pref == NULL) {
             prefs.unknown_prefs = TRUE;
@@ -4121,8 +5460,10 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
             /* "gui" prefix was added to column preferences for better organization
              * within the preferences file
              */
             /* "gui" prefix was added to column preferences for better organization
              * within the preferences file
              */
-            if ((strcmp(pref_name, PRS_COL_HIDDEN) == 0) ||
-                (strcmp(pref_name, PRS_COL_FMT) == 0)) {
+            if (module == gui_column_module) {
+                /* While this has a subtree, there is no apply callback, so no
+                 * need to use prefs_find_preference_with_submodule to update
+                 * containing_module. It would not be useful. */
                 pref = prefs_find_preference(module, pref_name);
             }
             else if (strcmp(module->name, "mgcp") == 0) {
                 pref = prefs_find_preference(module, pref_name);
             }
             else if (strcmp(module->name, "mgcp") == 0) {
@@ -4283,11 +5624,14 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
             } else if (strcmp(module->name, "smpp") == 0) {
                 /* Handle preferences that moved from SMPP. */
                 module_t *new_module = prefs_find_module("gsm-sms-ud");
             } else if (strcmp(module->name, "smpp") == 0) {
                 /* Handle preferences that moved from SMPP. */
                 module_t *new_module = prefs_find_module("gsm-sms-ud");
-                if (new_module){
-                    if (strcmp(dotp, "port_number_udh_means_wsp") == 0)
+                if (new_module) {
+                    if (strcmp(dotp, "port_number_udh_means_wsp") == 0) {
                         pref = prefs_find_preference(new_module, "port_number_udh_means_wsp");
                         pref = prefs_find_preference(new_module, "port_number_udh_means_wsp");
-                    else if (strcmp(dotp, "try_dissect_1st_fragment") == 0)
+                        containing_module = new_module;
+                    } else if (strcmp(dotp, "try_dissect_1st_fragment") == 0) {
                         pref = prefs_find_preference(new_module, "try_dissect_1st_fragment");
                         pref = prefs_find_preference(new_module, "try_dissect_1st_fragment");
+                        containing_module = new_module;
+                    }
                 }
             } else if (strcmp(module->name, "asn1") == 0) {
                 /* Handle old generic ASN.1 preferences (it's not really a
                 }
             } else if (strcmp(module->name, "asn1") == 0) {
                 /* Handle old generic ASN.1 preferences (it's not really a
@@ -4347,13 +5691,12 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
                     module_t *new_module = prefs_find_module("vlan");
                     if (new_module) {
                         pref = prefs_find_preference(new_module, "qinq_ethertype");
                     module_t *new_module = prefs_find_module("vlan");
                     if (new_module) {
                         pref = prefs_find_preference(new_module, "qinq_ethertype");
-                        module = new_module;
+                        containing_module = new_module;
                     }
                 }
             } else if (strcmp(module->name, "taps") == 0) {
                 /* taps preferences moved to "statistics" module */
                     }
                 }
             } else if (strcmp(module->name, "taps") == 0) {
                 /* taps preferences moved to "statistics" module */
-                if (strcmp(dotp, "update_interval") == 0 ||
-                    strcmp(dotp, "rtp_player_max_visible") == 0)
+                if (strcmp(dotp, "update_interval") == 0)
                     pref = prefs_find_preference(stats_module, dotp);
             } else if (strcmp(module->name, "packet_list") == 0) {
                 /* packet_list preferences moved to protocol module */
                     pref = prefs_find_preference(stats_module, dotp);
             } else if (strcmp(module->name, "packet_list") == 0) {
                 /* packet_list preferences moved to protocol module */
@@ -4379,7 +5722,14 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
         if (pref == NULL)
             return PREFS_SET_NO_SUCH_PREF;        /* no such preference */
 
         if (pref == NULL)
             return PREFS_SET_NO_SUCH_PREF;        /* no such preference */
 
-        switch (pref->type) {
+        type = pref->type;
+        if (IS_PREF_OBSOLETE(type)) {
+            return PREFS_SET_OBSOLETE;        /* no such preference any more */
+        } else {
+            RESET_PREF_OBSOLETE(type);
+        }
+
+        switch (type) {
 
         case PREF_UINT:
             /* XXX - give an error if it doesn't fit in a guint? */
 
         case PREF_UINT:
             /* XXX - give an error if it doesn't fit in a guint? */
@@ -4387,11 +5737,47 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
             if (p == value || *p != '\0')
                 return PREFS_SET_SYNTAX_ERR;        /* number was bad */
             if (*pref->varp.uint != uval) {
             if (p == value || *p != '\0')
                 return PREFS_SET_SYNTAX_ERR;        /* number was bad */
             if (*pref->varp.uint != uval) {
-                module->prefs_changed = TRUE;
+                containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
                 *pref->varp.uint = uval;
             }
             break;
                 *pref->varp.uint = uval;
             }
             break;
+        case PREF_DECODE_AS_UINT:
+        {
+            /* This is for backwards compatibility in case any of the preferences
+               that shared the "Decode As" preference name and used to be PREF_UINT
+               are now applied directly to the Decode As funtionality */
+
+            dissector_table_t sub_dissectors;
+            dissector_handle_t handle;
+
+            /* XXX - give an error if it doesn't fit in a guint? */
+            uval = (guint)strtoul(value, &p, pref->info.base);
+            if (p == value || *p != '\0')
+                return PREFS_SET_SYNTAX_ERR;        /* number was bad */
+
+            if (*pref->varp.uint != uval) {
+                containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+                *pref->varp.uint = uval;
 
 
+                /* Name of preference is the dissector table */
+                sub_dissectors = find_dissector_table(pref->name);
+                if (sub_dissectors != NULL) {
+                    handle = dissector_table_get_dissector_handle(sub_dissectors, module->title);
+                    if (handle != NULL) {
+                        if (uval != 0) {
+                            dissector_change_uint(pref->name, uval, handle);
+                            decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(uval), NULL, NULL);
+                        } else {
+                            dissector_delete_uint(pref->name, *pref->varp.uint, handle);
+                            decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), pref->varp.uint, NULL, NULL);
+                        }
+
+                        /* XXX - Do we save the decode_as_entries file here? */
+                    }
+                }
+            }
+            break;
+        }
         case PREF_BOOL:
             /* XXX - give an error if it's neither "true" nor "false"? */
             if (g_ascii_strcasecmp(value, "true") == 0)
         case PREF_BOOL:
             /* XXX - give an error if it's neither "true" nor "false"? */
             if (g_ascii_strcasecmp(value, "true") == 0)
@@ -4399,7 +5785,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
             else
                 bval = FALSE;
             if (*pref->varp.boolp != bval) {
             else
                 bval = FALSE;
             if (*pref->varp.boolp != bval) {
-                module->prefs_changed = TRUE;
+                containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
                 *pref->varp.boolp = bval;
             }
             break;
                 *pref->varp.boolp = bval;
             }
             break;
@@ -4409,33 +5795,88 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
             enum_val = find_val_for_string(value, pref->info.enum_info.enumvals,
                                            *pref->varp.enump);
             if (*pref->varp.enump != enum_val) {
             enum_val = find_val_for_string(value, pref->info.enum_info.enumvals,
                                            *pref->varp.enump);
             if (*pref->varp.enump != enum_val) {
-                module->prefs_changed = TRUE;
+                containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
                 *pref->varp.enump = enum_val;
             }
             break;
 
         case PREF_STRING:
                 *pref->varp.enump = enum_val;
             }
             break;
 
         case PREF_STRING:
-        case PREF_FILENAME:
+        case PREF_SAVE_FILENAME:
+        case PREF_OPEN_FILENAME:
         case PREF_DIRNAME:
         case PREF_DIRNAME:
-            prefs_set_string_like_value(pref, value, &module->prefs_changed);
+            containing_module->prefs_changed_flags |= prefs_set_string_value(pref, value, pref_current);
             break;
 
         case PREF_RANGE:
         {
             if (!prefs_set_range_value_work(pref, value, return_range_errors,
             break;
 
         case PREF_RANGE:
         {
             if (!prefs_set_range_value_work(pref, value, return_range_errors,
-                                            &module->prefs_changed))
+                                            &containing_module->prefs_changed_flags))
+                return PREFS_SET_SYNTAX_ERR;        /* number was bad */
+            break;
+        }
+        case PREF_DECODE_AS_RANGE:
+        {
+            /* This is for backwards compatibility in case any of the preferences
+               that shared the "Decode As" preference name and used to be PREF_RANGE
+               are now applied directly to the Decode As funtionality */
+            range_t *newrange;
+            dissector_table_t sub_dissectors;
+            dissector_handle_t handle;
+            guint32 i, j;
+
+            if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
+                                       return_range_errors) != CVT_NO_ERROR) {
                 return PREFS_SET_SYNTAX_ERR;        /* number was bad */
                 return PREFS_SET_SYNTAX_ERR;        /* number was bad */
+            }
+
+            if (!ranges_are_equal(*pref->varp.range, newrange)) {
+                wmem_free(wmem_epan_scope(), *pref->varp.range);
+                *pref->varp.range = newrange;
+                containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+                /* Name of preference is the dissector table */
+                sub_dissectors = find_dissector_table(pref->name);
+                if (sub_dissectors != NULL) {
+                    handle = dissector_table_get_dissector_handle(sub_dissectors, module->title);
+                    if (handle != NULL) {
+                        /* Delete all of the old values from the dissector table */
+                               for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+                                       for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+                                dissector_delete_uint(pref->name, j, handle);
+                                decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+                            }
+
+                            dissector_delete_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+                            decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+                               }
+
+                        /* Add new values to the dissector table */
+                               for (i = 0; i < newrange->nranges; i++) {
+                                       for (j = newrange->ranges[i].low; j < newrange->ranges[i].high; j++) {
+                                dissector_change_uint(pref->name, j, handle);
+                                decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+                            }
+
+                            dissector_change_uint(pref->name, newrange->ranges[i].high, handle);
+                            decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(newrange->ranges[i].high), NULL, NULL);
+                               }
+
+                        /* XXX - Do we save the decode_as_entries file here? */
+                    }
+                }
+            } else {
+                wmem_free(wmem_epan_scope(), newrange);
+            }
             break;
         }
 
         case PREF_COLOR:
         {
             cval = strtoul(value, NULL, 16);
             break;
         }
 
         case PREF_COLOR:
         {
             cval = strtoul(value, NULL, 16);
-            pref->varp.colorp->pixel = 0;
             if ((pref->varp.colorp->red != RED_COMPONENT(cval)) ||
                 (pref->varp.colorp->green != GREEN_COMPONENT(cval)) ||
                 (pref->varp.colorp->blue != BLUE_COMPONENT(cval))) {
             if ((pref->varp.colorp->red != RED_COMPONENT(cval)) ||
                 (pref->varp.colorp->green != GREEN_COMPONENT(cval)) ||
                 (pref->varp.colorp->blue != BLUE_COMPONENT(cval))) {
-                module->prefs_changed = TRUE;
+                containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
                 pref->varp.colorp->red   = RED_COMPONENT(cval);
                 pref->varp.colorp->green = GREEN_COMPONENT(cval);
                 pref->varp.colorp->blue  = BLUE_COMPONENT(cval);
                 pref->varp.colorp->red   = RED_COMPONENT(cval);
                 pref->varp.colorp->green = GREEN_COMPONENT(cval);
                 pref->varp.colorp->blue  = BLUE_COMPONENT(cval);
@@ -4444,16 +5885,13 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
         }
 
         case PREF_CUSTOM:
         }
 
         case PREF_CUSTOM:
-            return pref->custom_cbs.set_cb(pref, value, &module->prefs_changed);
+            return pref->custom_cbs.set_cb(pref, value, &containing_module->prefs_changed_flags);
 
         case PREF_STATIC_TEXT:
         case PREF_UAT:
         {
             break;
         }
 
         case PREF_STATIC_TEXT:
         case PREF_UAT:
         {
             break;
         }
-
-        case PREF_OBSOLETE:
-            return PREFS_SET_OBSOLETE;        /* no such preference any more */
         }
     }
 
         }
     }
 
@@ -4469,12 +5907,21 @@ const char *
 prefs_pref_type_name(pref_t *pref)
 {
     const char *type_name = "[Unknown]";
 prefs_pref_type_name(pref_t *pref)
 {
     const char *type_name = "[Unknown]";
+    int type;
 
     if (!pref) {
         return type_name; /* ...or maybe assert? */
     }
 
 
     if (!pref) {
         return type_name; /* ...or maybe assert? */
     }
 
-    switch (pref->type) {
+    type = pref->type;
+
+    if (IS_PREF_OBSOLETE(type)) {
+        type_name = "Obsolete";
+    } else {
+        RESET_PREF_OBSOLETE(type);
+    }
+
+    switch (type) {
 
     case PREF_UINT:
         switch (pref->info.base) {
 
     case PREF_UINT:
         switch (pref->info.base) {
@@ -4505,7 +5952,8 @@ prefs_pref_type_name(pref_t *pref)
         type_name = "String";
         break;
 
         type_name = "String";
         break;
 
-    case PREF_FILENAME:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
         type_name = "Filename";
         break;
 
         type_name = "Filename";
         break;
 
@@ -4527,8 +5975,12 @@ prefs_pref_type_name(pref_t *pref)
         type_name = "Custom";
         break;
 
         type_name = "Custom";
         break;
 
-    case PREF_OBSOLETE:
-        type_name = "Obsolete";
+    case PREF_DECODE_AS_UINT:
+        type_name = "Decode As value";
+        break;
+
+    case PREF_DECODE_AS_RANGE:
+        type_name = "Range (for Decode As)";
         break;
 
     case PREF_STATIC_TEXT:
         break;
 
     case PREF_STATIC_TEXT:
@@ -4542,16 +5994,65 @@ prefs_pref_type_name(pref_t *pref)
     return type_name;
 }
 
     return type_name;
 }
 
+unsigned int
+prefs_get_effect_flags(pref_t *pref)
+{
+    if (pref == NULL)
+        return 0;
+
+    return pref->effect_flags;
+}
+
+void
+prefs_set_effect_flags(pref_t *pref, unsigned int flags)
+{
+    if (pref != NULL) {
+        pref->effect_flags = flags;
+    }
+}
+
+void
+prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags)
+{
+    prefs_set_effect_flags(prefs_find_preference(module, pref), flags);
+}
+
+unsigned int
+prefs_get_module_effect_flags(module_t * module)
+{
+    if (module == NULL)
+        return 0;
+
+    return module->effect_flags;
+}
+
+void
+prefs_set_module_effect_flags(module_t * module, unsigned int flags)
+{
+    if (module != NULL) {
+        module->effect_flags = flags;
+    }
+}
+
 char *
 prefs_pref_type_description(pref_t *pref)
 {
     const char *type_desc = "An unknown preference type";
 char *
 prefs_pref_type_description(pref_t *pref)
 {
     const char *type_desc = "An unknown preference type";
+    int type;
 
     if (!pref) {
         return g_strdup_printf("%s.", type_desc); /* ...or maybe assert? */
     }
 
 
     if (!pref) {
         return g_strdup_printf("%s.", type_desc); /* ...or maybe assert? */
     }
 
-    switch (pref->type) {
+    type = pref->type;
+
+    if (IS_PREF_OBSOLETE(type)) {
+        type_desc = "An obsolete preference";
+    } else {
+        RESET_PREF_OBSOLETE(type);
+    }
+
+    switch (type) {
 
     case PREF_UINT:
         switch (pref->info.base) {
 
     case PREF_UINT:
         switch (pref->info.base) {
@@ -4593,7 +6094,8 @@ prefs_pref_type_description(pref_t *pref)
         type_desc = "A string";
         break;
 
         type_desc = "A string";
         break;
 
-    case PREF_FILENAME:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
         type_desc = "A path to a file";
         break;
 
         type_desc = "A path to a file";
         break;
 
@@ -4619,8 +6121,12 @@ prefs_pref_type_description(pref_t *pref)
         type_desc = "A custom value";
         break;
 
         type_desc = "A custom value";
         break;
 
-    case PREF_OBSOLETE:
-        type_desc = "An obsolete preference";
+    case PREF_DECODE_AS_UINT:
+        type_desc = "An integer value used in Decode As";
+        break;
+
+    case PREF_DECODE_AS_RANGE:
+        type_desc = "A string denoting an positive integer range for Decode As";
         break;
 
     case PREF_STATIC_TEXT:
         break;
 
     case PREF_STATIC_TEXT:
@@ -4637,11 +6143,25 @@ prefs_pref_type_description(pref_t *pref)
     return g_strdup(type_desc);
 }
 
     return g_strdup(type_desc);
 }
 
-static gboolean
-prefs_pref_is_default(pref_t *pref) {
+gboolean
+prefs_pref_is_default(pref_t *pref)
+{
+    int type;
     if (!pref) return FALSE;
 
     if (!pref) return FALSE;
 
-    switch (pref->type) {
+    type = pref->type;
+    if (IS_PREF_OBSOLETE(type)) {
+        return FALSE;
+    } else {
+        RESET_PREF_OBSOLETE(type);
+    }
+
+    switch (type) {
+
+    case PREF_DECODE_AS_UINT:
+        if (pref->default_val.uint == *pref->varp.uint)
+            return TRUE;
+        break;
 
     case PREF_UINT:
         if (pref->default_val.uint == *pref->varp.uint)
 
     case PREF_UINT:
         if (pref->default_val.uint == *pref->varp.uint)
@@ -4659,12 +6179,14 @@ prefs_pref_is_default(pref_t *pref) {
         break;
 
     case PREF_STRING:
         break;
 
     case PREF_STRING:
-    case PREF_FILENAME:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
     case PREF_DIRNAME:
         if (!(g_strcmp0(pref->default_val.string, *pref->varp.string)))
             return TRUE;
         break;
 
     case PREF_DIRNAME:
         if (!(g_strcmp0(pref->default_val.string, *pref->varp.string)))
             return TRUE;
         break;
 
+    case PREF_DECODE_AS_RANGE:
     case PREF_RANGE:
     {
         if ((ranges_are_equal(pref->default_val.range, *pref->varp.range)))
     case PREF_RANGE:
     {
         if ((ranges_are_equal(pref->default_val.range, *pref->varp.range)))
@@ -4684,7 +6206,6 @@ prefs_pref_is_default(pref_t *pref) {
     case PREF_CUSTOM:
         return pref->custom_cbs.is_default_cb(pref);
 
     case PREF_CUSTOM:
         return pref->custom_cbs.is_default_cb(pref);
 
-    case PREF_OBSOLETE:
     case PREF_STATIC_TEXT:
     case PREF_UAT:
         return FALSE;
     case PREF_STATIC_TEXT:
     case PREF_UAT:
         return FALSE;
@@ -4700,6 +6221,7 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
     void *valp; /* pointer to preference value */
     color_t *pref_color;
     gchar *tmp_value, *ret_value;
     void *valp; /* pointer to preference value */
     color_t *pref_color;
     gchar *tmp_value, *ret_value;
+    int type;
 
     if (!pref) {
         return g_strdup(pref_text);
 
     if (!pref) {
         return g_strdup(pref_text);
@@ -4725,8 +6247,16 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
             return g_strdup(pref_text);
     }
 
             return g_strdup(pref_text);
     }
 
-    switch (pref->type) {
+    type = pref->type;
+    if (IS_PREF_OBSOLETE(type)) {
+        pref_text = "[Obsolete]";
+    } else {
+        RESET_PREF_OBSOLETE(type);
+    }
+
+    switch (type) {
 
 
+    case PREF_DECODE_AS_UINT:
     case PREF_UINT:
     {
         guint pref_uint = *(guint *) valp;
     case PREF_UINT:
     {
         guint pref_uint = *(guint *) valp;
@@ -4745,7 +6275,7 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
     }
 
     case PREF_BOOL:
     }
 
     case PREF_BOOL:
-        return g_strdup_printf("%s", (*(gboolean *) valp) ? "TRUE" : "FALSE");
+        return g_strdup((*(gboolean *) valp) ? "TRUE" : "FALSE");
 
     case PREF_ENUM:
     {
 
     case PREF_ENUM:
     {
@@ -4767,10 +6297,12 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
     }
 
     case PREF_STRING:
     }
 
     case PREF_STRING:
-    case PREF_FILENAME:
+    case PREF_SAVE_FILENAME:
+    case PREF_OPEN_FILENAME:
     case PREF_DIRNAME:
         return g_strdup(*(const char **) valp);
 
     case PREF_DIRNAME:
         return g_strdup(*(const char **) valp);
 
+    case PREF_DECODE_AS_RANGE:
     case PREF_RANGE:
         /* Convert wmem to g_alloc memory */
         tmp_value = range_convert_range(NULL, *(range_t **) valp);
     case PREF_RANGE:
         /* Convert wmem to g_alloc memory */
         tmp_value = range_convert_range(NULL, *(range_t **) valp);
@@ -4790,10 +6322,6 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
         pref_text = "[Custom]";
         break;
 
         pref_text = "[Custom]";
         break;
 
-    case PREF_OBSOLETE:
-        pref_text = "[Obsolete]";
-        break;
-
     case PREF_STATIC_TEXT:
         pref_text = "[Static text]";
         break;
     case PREF_STATIC_TEXT:
         pref_text = "[Static text]";
         break;
@@ -4824,9 +6352,11 @@ write_pref(gpointer data, gpointer user_data)
     write_pref_arg_t *arg = (write_pref_arg_t *)user_data;
     gchar **desc_lines;
     int i;
     write_pref_arg_t *arg = (write_pref_arg_t *)user_data;
     gchar **desc_lines;
     int i;
+    int type;
 
 
-    switch (pref->type) {
-    case PREF_OBSOLETE:
+    type = pref->type;
+
+    if (IS_PREF_OBSOLETE(type)) {
         /*
          * This preference is no longer supported; it's not a
          * real preference, so we don't write it out (i.e., we
         /*
          * This preference is no longer supported; it's not a
          * real preference, so we don't write it out (i.e., we
@@ -4834,11 +6364,20 @@ write_pref(gpointer data, gpointer user_data)
          * preferences, and we weren't called in the first place).
          */
         return;
          * preferences, and we weren't called in the first place).
          */
         return;
+    } else {
+        RESET_PREF_OBSOLETE(type);
+    }
+
+    switch (type) {
 
     case PREF_STATIC_TEXT:
     case PREF_UAT:
         /* Nothing to do; don't bother printing the description */
         return;
 
     case PREF_STATIC_TEXT:
     case PREF_UAT:
         /* Nothing to do; don't bother printing the description */
         return;
+    case PREF_DECODE_AS_UINT:
+    case PREF_DECODE_AS_RANGE:
+        /* Data is saved through Decode As mechanism and not part of preferences file */
+        return;
     default:
         break;
     }
     default:
         break;
     }
@@ -4890,6 +6429,35 @@ write_pref(gpointer data, gpointer user_data)
 
 }
 
 
 }
 
+static void
+count_non_uat_pref(gpointer data, gpointer user_data)
+{
+    pref_t *pref = (pref_t *)data;
+    int *arg = (int *)user_data;
+
+    switch (pref->type)
+    {
+    case PREF_UAT:
+    case PREF_OBSOLETE:
+    case PREF_DECODE_AS_UINT:
+    case PREF_DECODE_AS_RANGE:
+        //These types are not written in preference file
+        break;
+    default:
+        (*arg)++;
+        break;
+    }
+}
+
+static int num_non_uat_prefs(module_t *module)
+{
+    int num = 0;
+
+    g_list_foreach(module->prefs, count_non_uat_pref, &num);
+
+    return num;
+}
+
 /*
  * Write out all preferences for a module.
  */
 /*
  * Write out all preferences for a module.
  */
@@ -4907,7 +6475,7 @@ write_module_prefs(module_t *module, gpointer user_data)
     /* Write a header for the main modules and GUI sub-modules */
     if (((module->parent == NULL) || (module->parent == gui_module)) &&
         ((prefs_module_has_submodules(module)) ||
     /* Write a header for the main modules and GUI sub-modules */
     if (((module->parent == NULL) || (module->parent == gui_module)) &&
         ((prefs_module_has_submodules(module)) ||
-         (module->numprefs > 0) ||
+         (num_non_uat_prefs(module) > 0) ||
          (module->name == NULL))) {
          if ((module->name == NULL) && (module->parent != NULL)) {
             fprintf(gui_pref_arg->pf, "\n####### %s: %s ########\n", module->parent->title, module->title);
          (module->name == NULL))) {
          if ((module->name == NULL) && (module->parent != NULL)) {
             fprintf(gui_pref_arg->pf, "\n####### %s: %s ########\n", module->parent->title, module->title);
@@ -4977,23 +6545,6 @@ write_prefs(char **pf_path_return)
 
     write_module_prefs(gui_module, &write_gui_pref_info);
 
 
     write_module_prefs(gui_module, &write_gui_pref_info);
 
-    {
-        struct filter_expression *fe = *(struct filter_expression **)prefs.filter_expressions;
-
-        if (fe != NULL)
-            fprintf(pf, "\n####### Filter Expressions ########\n");
-
-        while (fe != NULL) {
-            if (fe->deleted == FALSE) {
-                fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_LABEL, fe->label);
-                fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_ENABLED,
-                        fe->enabled == TRUE ? "TRUE" : "FALSE");
-                fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_EXPR, fe->expression);
-            }
-            fe = fe->next;
-        }
-    }
-
     write_gui_pref_info.is_gui_module = FALSE;
     prefs_modules_foreach_submodules(NULL, write_module_prefs, &write_gui_pref_info);
 
     write_gui_pref_info.is_gui_module = FALSE;
     prefs_modules_foreach_submodules(NULL, write_module_prefs, &write_gui_pref_info);