Add ability for preferences to determine what they can change.

Add flags field to preference structure to help determine what
areas of Wireshark are affected by a preference changing.  The
intent is to be able to distinguish dissection from GUI or other
changes that are not dissection.

The default is to have all preferences affect dissection, but their
flags can be changed.  This patch doesn't change any flags from the
default.

Change-Id: Ied5ae961bc3f33f5b730b2892fff3fa0898380b8
Reviewed-on: https://code.wireshark.org/review/25171
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2018-01-05 23:39:55 -05:00
parent a65391f901
commit eef3c8434d
17 changed files with 258 additions and 132 deletions

View File

@ -985,10 +985,12 @@ libwireshark.so.0 libwireshark0 #MINVER#
prefs_get_color_value@Base 2.3.0
prefs_get_control@Base 2.3.0
prefs_get_description@Base 2.3.0
prefs_get_effect_flags@Base 2.5.0
prefs_get_enum_value@Base 2.3.0
prefs_get_enum_radiobuttons@Base 2.3.0
prefs_get_enumvals@Base 2.3.0
prefs_get_gui_type@Base 2.3.0
prefs_get_module_effect_flags@Base 2.5.0
prefs_get_max_value@Base 2.3.0
prefs_get_name@Base 2.3.0
prefs_get_ordinal@Base 2.3.0
@ -1037,8 +1039,11 @@ libwireshark.so.0 libwireshark0 #MINVER#
prefs_set_bool_value@Base 2.3.0
prefs_set_color_value@Base 2.3.0
prefs_set_control@Base 2.3.0
prefs_set_effect_flags@Base 2.5.0
prefs_set_effect_flags_by_name@Base 2.5.0
prefs_set_enum_value@Base 2.3.0
prefs_set_gui_theme_is_dark@Base 2.5.0
prefs_set_module_effect_flags@Base 2.5.0
prefs_set_pref@Base 1.9.1
prefs_set_range_value@Base 2.1.0
prefs_set_range_value_work@Base 2.3.0

View File

@ -272,7 +272,7 @@ read_set_decode_as_entries(gchar *key, const gchar *value,
}
prefs_add_decode_as_value(pref_value, (guint)long_value, replace);
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
}
}

View File

@ -45,7 +45,7 @@ struct pref_module {
struct pref_module *parent; /**< parent module */
wmem_tree_t *submodules; /**< list of its submodules */
int numprefs; /**< number of non-obsolete preferences */
gboolean prefs_changed; /**< if TRUE, a preference has changed since we last checked */
unsigned int prefs_changed_flags; /**< Bitmask of the types of changes done by module preferences since we last checked */
gboolean obsolete; /**< if TRUE, this is a module that used to
* exist but no longer does
*/
@ -56,6 +56,9 @@ struct pref_module {
* use simple GUI controls to change the options. In general, the "general"
* Wireshark preferences should have this set to FALSE, while the protocol
* modules will have this set to TRUE */
unsigned int effect_flags; /**< Flags of types effected by preference (PREF_TYPE_DISSECTION, PREF_EFFECT_CAPTURE, etc).
These flags will be set in all module's preferences on creation. Flags must be non-zero
to ensure saving to disk */
};
typedef struct {
@ -71,7 +74,7 @@ WS_DLL_PUBLIC module_t *protocols_module;
typedef void (*pref_custom_free_cb) (pref_t* pref);
typedef void (*pref_custom_reset_cb) (pref_t* pref);
typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const gchar* value, gboolean* changed);
typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const gchar* value, unsigned int* changed_flags);
/* typedef void (*pref_custom_write_cb) (pref_t* pref, write_pref_arg_t* arg); Deprecated. */
/* pref_custom_type_name_cb should return NULL for internal / hidden preferences. */
typedef const char * (*pref_custom_type_name_cb) (void);
@ -145,6 +148,71 @@ gui_type_t prefs_get_gui_type(pref_t *pref);
WS_DLL_PUBLIC guint32 prefs_get_max_value(pref_t *pref);
/* Bitmask of flags for how a preference could affect changes in Wireshark */
#define PREF_EFFECT_DISSECTION (1u << 0)
#define PREF_EFFECT_CAPTURE (1u << 1)
#define PREF_EFFECT_GUI (1u << 2)
#define PREF_EFFECT_FONT (1u << 3)
#define PREF_EFFECT_CUSTOM (1u << 31)
/** Fetch flags that show preference effect
*
* @param pref A preference.
*
* @return A bitmask of the types of things the preference will
* effect.
*/
WS_DLL_PUBLIC
unsigned int prefs_get_effect_flags(pref_t *pref);
/** Set flags for preference effect
* The intention is to distinguish preferences that affect
* dissection from those that don't. A bitmask was added to
* provide great flexibility in the types of things that a
* preference could affect.
*
* @param pref A preference.
* @param flags Bitmask of flags to apply to preference. Note that flags
* must be non-zero to ensure preference is properly saved to disk.
*
*/
WS_DLL_PUBLIC
void prefs_set_effect_flags(pref_t *pref, unsigned int flags);
/** Same as prefs_set_effect_flags, just different way to get preference
*/
WS_DLL_PUBLIC
void prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags);
/** Fetch flags that show module's preferences effect
* The flag values of the module will be applied to any individual preferences
* of the module when they are created
*
* @param module A preference module.
*
* @return A bitmask of the types of things the module's preferences will
* effect.
*/
WS_DLL_PUBLIC
unsigned int prefs_get_module_effect_flags(module_t * module);
/** Set flags for module's preferences effect
* The intention is to distinguish preferences that affect
* dissection from those that don't. Since modules are a grouping
* of preferences, it's likely that a whole module will want the
* same flags for its preferences. The flag values of the module will
* be applied to any individual preferences of the module when they
* are created
*
* @param module A preference module.
* @param flags Bitmask of flags to apply to module. Note that flags
* must be non-zero to ensure preferences are properly saved to disk.
*
*/
WS_DLL_PUBLIC
void prefs_set_module_effect_flags(module_t * module, unsigned int flags);
// GTK only
WS_DLL_PUBLIC void* prefs_get_control(pref_t *pref);
WS_DLL_PUBLIC void prefs_set_control(pref_t *pref, void* control);
@ -152,10 +220,10 @@ WS_DLL_PUBLIC int prefs_get_ordinal(pref_t *pref);
WS_DLL_PUBLIC
gboolean 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);
WS_DLL_PUBLIC
gboolean
unsigned int
prefs_set_stashed_range_value(pref_t *pref, const gchar *value);
/** Add a range value of a range preference. */
@ -169,16 +237,16 @@ void
prefs_range_remove_value(pref_t *pref, guint32 val);
WS_DLL_PUBLIC gboolean prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source);
WS_DLL_PUBLIC unsigned int prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source);
WS_DLL_PUBLIC gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source);
WS_DLL_PUBLIC void prefs_invert_bool_value(pref_t *pref, pref_source_t source);
WS_DLL_PUBLIC gboolean prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source);
WS_DLL_PUBLIC unsigned int prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source);
WS_DLL_PUBLIC guint prefs_get_uint_base(pref_t *pref);
WS_DLL_PUBLIC guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source);
WS_DLL_PUBLIC gboolean prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source);
WS_DLL_PUBLIC unsigned int prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source);
WS_DLL_PUBLIC gint prefs_get_enum_value(pref_t *pref, pref_source_t source);
WS_DLL_PUBLIC const enum_val_t* prefs_get_enumvals(pref_t *pref);
WS_DLL_PUBLIC gboolean prefs_get_enum_radiobuttons(pref_t *pref);
@ -186,7 +254,7 @@ WS_DLL_PUBLIC gboolean prefs_get_enum_radiobuttons(pref_t *pref);
WS_DLL_PUBLIC gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source);
WS_DLL_PUBLIC color_t* prefs_get_color_value(pref_t *pref, pref_source_t source);
WS_DLL_PUBLIC gboolean prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
WS_DLL_PUBLIC unsigned int prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
WS_DLL_PUBLIC char* prefs_get_string_value(pref_t *pref, pref_source_t source);
WS_DLL_PUBLIC struct epan_uat* prefs_get_uat_value(pref_t *pref);

View File

@ -204,6 +204,8 @@ struct preference {
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;
@ -496,9 +498,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->prefs_changed = FALSE;
module->prefs_changed_flags = 0;
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?
@ -885,10 +889,10 @@ call_apply_cb(const void *key _U_, void *value, void *data _U_)
if (module->obsolete)
return FALSE;
if (module->prefs_changed) {
if (module->prefs_changed_flags) {
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);
@ -916,7 +920,7 @@ prefs_apply_all(void)
void
prefs_apply(module_t *module)
{
if (module && module->prefs_changed)
if (module && module->prefs_changed_flags)
call_apply_cb(NULL, module, NULL);
}
@ -940,6 +944,9 @@ register_preference(module_t *module, const char *name, const char *title,
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;
@ -1179,28 +1186,28 @@ prefs_register_bool_preference(module_t *module, const char *name,
preference->default_val.boolval = *var;
}
gboolean prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source)
unsigned int prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source)
{
gboolean changed = FALSE;
unsigned int changed = 0;
switch (source)
{
case pref_default:
if (pref->default_val.boolval != value) {
pref->default_val.boolval = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
case pref_stashed:
if (pref->stashed_val.boolval != value) {
pref->stashed_val.boolval = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
case pref_current:
if (*pref->varp.boolp != value) {
*pref->varp.boolp = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
default:
@ -1274,28 +1281,28 @@ prefs_register_enum_preference(module_t *module, const char *name,
preference->info.enum_info.radio_buttons = radio_buttons;
}
gboolean prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source)
unsigned int prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source)
{
gboolean changed = FALSE;
unsigned int changed = 0;
switch (source)
{
case pref_default:
if (pref->default_val.enumval != value) {
pref->default_val.enumval = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
case pref_stashed:
if (pref->stashed_val.enumval != value) {
pref->stashed_val.enumval = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
case pref_current:
if (*pref->varp.enump != value) {
*pref->varp.enump = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
default:
@ -1379,17 +1386,17 @@ register_string_like_preference(module_t *module, const char *name,
/*
* For use by UI code that sets preferences.
*/
gboolean
unsigned int
prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source)
{
gboolean changed = FALSE;
unsigned int changed = 0;
switch (source)
{
case pref_default:
if (*pref->default_val.string) {
if (strcmp(pref->default_val.string, value) != 0) {
changed = TRUE;
changed = prefs_get_effect_flags(pref);
g_free(pref->default_val.string);
pref->default_val.string = g_strdup(value);
}
@ -1400,7 +1407,7 @@ prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source)
case pref_stashed:
if (pref->stashed_val.string) {
if (strcmp(pref->stashed_val.string, value) != 0) {
changed = TRUE;
changed = prefs_get_effect_flags(pref);
g_free(pref->stashed_val.string);
pref->stashed_val.string = g_strdup(value);
}
@ -1411,7 +1418,7 @@ prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source)
case pref_current:
if (*pref->varp.string) {
if (strcmp(*pref->varp.string, value) != 0) {
changed = TRUE;
changed = prefs_get_effect_flags(pref);
g_free(*pref->varp.string);
*pref->varp.string = g_strdup(value);
}
@ -1537,7 +1544,7 @@ prefs_register_range_preference(module_t *module, const char *name,
gboolean
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;
@ -1547,7 +1554,7 @@ prefs_set_range_value_work(pref_t *pref, const gchar *value,
}
if (!ranges_are_equal(*pref->varp.range, newrange)) {
*changed = TRUE;
*changed_flags |= prefs_get_effect_flags(pref);
wmem_free(wmem_epan_scope(), *pref->varp.range);
*pref->varp.range = newrange;
} else {
@ -1559,14 +1566,14 @@ prefs_set_range_value_work(pref_t *pref, const gchar *value,
/*
* For use by UI code that sets preferences.
*/
gboolean
unsigned int
prefs_set_stashed_range_value(pref_t *pref, const gchar *value)
{
range_t *newrange;
if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
TRUE) != CVT_NO_ERROR) {
return FALSE; /* number was bad */
return 0; /* number was bad */
}
if (!ranges_are_equal(pref->stashed_val.range, newrange)) {
@ -1575,7 +1582,7 @@ prefs_set_stashed_range_value(pref_t *pref, const gchar *value)
} else {
wmem_free(wmem_epan_scope(), newrange);
}
return TRUE;
return prefs_get_effect_flags(pref);
}
@ -1987,7 +1994,7 @@ pref_unstash(pref_t *pref, gpointer unstash_data_p)
case PREF_DECODE_AS_UINT:
if (*pref->varp.uint != pref->stashed_val.uint) {
unstash_data->module->prefs_changed = TRUE;
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) {
@ -2011,21 +2018,21 @@ pref_unstash(pref_t *pref, gpointer unstash_data_p)
case PREF_UINT:
if (*pref->varp.uint != pref->stashed_val.uint) {
unstash_data->module->prefs_changed = TRUE;
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 = TRUE;
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 = TRUE;
unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.enump = pref->stashed_val.enumval;
}
break;
@ -2035,7 +2042,7 @@ pref_unstash(pref_t *pref, gpointer unstash_data_p)
case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0) {
unstash_data->module->prefs_changed = TRUE;
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);
}
@ -2044,7 +2051,7 @@ pref_unstash(pref_t *pref, gpointer unstash_data_p)
case PREF_DECODE_AS_RANGE:
if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) {
guint32 i, j;
unstash_data->module->prefs_changed = TRUE;
unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
if (unstash_data->handle_decode_as) {
sub_dissectors = find_dissector_table(pref->name);
@ -2089,14 +2096,19 @@ pref_unstash(pref_t *pref, gpointer unstash_data_p)
case PREF_RANGE:
if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) {
unstash_data->module->prefs_changed = TRUE;
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:
*pref->varp.colorp = pref->stashed_val.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:
@ -2348,14 +2360,14 @@ console_log_level_reset_cb(pref_t* pref)
}
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) {
*changed = TRUE;
*changed_flags = prefs_get_effect_flags(pref);
*pref->varp.uint = uval;
}
@ -2403,13 +2415,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
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;
(*changed) |= prefs_set_string_value(pref, value, pref_current);
(*changed_flags) |= prefs_set_string_value(pref, value, pref_current);
/*
* Set the "visible" flag for the existing columns; we need to
@ -2496,7 +2508,7 @@ column_num_reset_cb(pref_t* pref)
}
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;
@ -2596,7 +2608,7 @@ column_format_reset_cb(pref_t* pref)
}
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;
@ -2800,7 +2812,7 @@ capture_column_reset_cb(pref_t* pref)
}
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;
@ -2920,9 +2932,9 @@ capture_column_to_str_cb(pref_t* pref, gboolean default_val)
}
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)
{
(*changed) |= prefs_set_string_value(pref, value, pref_current);
(*changed_flags) |= prefs_set_string_value(pref, value, pref_current);
return PREFS_SET_OK;
}
@ -4712,27 +4724,27 @@ 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);
}
gboolean prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source)
unsigned int prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source)
{
gboolean changed = FALSE;
unsigned int changed = 0;
switch (source)
{
case pref_default:
if (pref->default_val.uint != value) {
pref->default_val.uint = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
case pref_stashed:
if (pref->stashed_val.uint != value) {
pref->stashed_val.uint = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
case pref_current:
if (*pref->varp.uint != value) {
*pref->varp.uint = value;
changed = TRUE;
changed = prefs_get_effect_flags(pref);
}
break;
default:
@ -5235,7 +5247,7 @@ deprecated_port_pref(gchar *pref_name, const gchar *value)
pref = prefs_find_preference(module, port_prefs[i].table_name);
if (pref != NULL)
{
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.uint = uval;
}
@ -5280,7 +5292,7 @@ deprecated_port_pref(gchar *pref_name, const gchar *value)
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))
if (!prefs_set_range_value_work(pref, value, TRUE, &module->prefs_changed_flags))
{
return FALSE; /* number was bad */
}
@ -5777,7 +5789,7 @@ 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) {
containing_module->prefs_changed = TRUE;
containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.uint = uval;
}
break;
@ -5796,7 +5808,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
return PREFS_SET_SYNTAX_ERR; /* number was bad */
if (*pref->varp.uint != uval) {
containing_module->prefs_changed = TRUE;
containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.uint = uval;
/* Name of preference is the dissector table */
@ -5825,7 +5837,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
else
bval = FALSE;
if (*pref->varp.boolp != bval) {
containing_module->prefs_changed = TRUE;
containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.boolp = bval;
}
break;
@ -5835,7 +5847,7 @@ 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) {
containing_module->prefs_changed = TRUE;
containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.enump = enum_val;
}
break;
@ -5844,13 +5856,13 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
case PREF_SAVE_FILENAME:
case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
containing_module->prefs_changed |= prefs_set_string_value(pref, value, pref_current);
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,
&containing_module->prefs_changed))
&containing_module->prefs_changed_flags))
return PREFS_SET_SYNTAX_ERR; /* number was bad */
break;
}
@ -5872,7 +5884,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
if (!ranges_are_equal(*pref->varp.range, newrange)) {
wmem_free(wmem_epan_scope(), *pref->varp.range);
*pref->varp.range = newrange;
containing_module->prefs_changed = TRUE;
containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
/* Name of preference is the dissector table */
sub_dissectors = find_dissector_table(pref->name);
@ -5916,7 +5928,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
if ((pref->varp.colorp->red != RED_COMPONENT(cval)) ||
(pref->varp.colorp->green != GREEN_COMPONENT(cval)) ||
(pref->varp.colorp->blue != BLUE_COMPONENT(cval))) {
containing_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);
@ -5925,7 +5937,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
}
case PREF_CUSTOM:
return pref->custom_cbs.set_cb(pref, value, &containing_module->prefs_changed);
return pref->custom_cbs.set_cb(pref, value, &containing_module->prefs_changed_flags);
case PREF_STATIC_TEXT:
case PREF_UAT:
@ -6034,6 +6046,46 @@ prefs_pref_type_name(pref_t *pref)
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)
{

View File

@ -562,7 +562,7 @@ load_wlan_driver_wep_keys(void)
* Signal that we've changed things, and run the 802.11 dissector's
* callback
*/
wlan_prefs->prefs_changed = TRUE;
wlan_prefs->prefs_changed_flags |= PREF_EFFECT_DISSECTION;
prefs_apply(wlan_prefs);
@ -772,7 +772,7 @@ save_wlan_driver_wep_keys(void)
/* Signal that we've changed things, and run the 802.11 dissector's
* callback */
wlan_prefs->prefs_changed = TRUE;
wlan_prefs->prefs_changed_flags |= PREF_EFFECT_DISSECTION;
/* Apply changes for the specified preference */
prefs_apply(wlan_prefs);
@ -829,7 +829,7 @@ save_wlan_wireshark_wep_keys(GList* key_ls)
/* Signal that we've changed things, and run the 802.11 dissector's
* callback */
wlan_prefs->prefs_changed = TRUE;
wlan_prefs->prefs_changed_flags |= PREF_EFFECT_DISSECTION;
/* Apply changes for the specified preference */
prefs_apply(wlan_prefs);
@ -1469,7 +1469,7 @@ set_wireshark_decryption(gboolean on_off)
* Signal that we've changed things, and run the 802.11 dissector's
* callback
*/
wlan_prefs->prefs_changed = TRUE;
wlan_prefs->prefs_changed_flags |= PREF_EFFECT_DISSECTION;
prefs_apply(wlan_prefs);
}

View File

@ -706,7 +706,7 @@ decode_simple (GtkWidget *notebook_pg)
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(temp_handle)));
pref_value = prefs_find_preference(module, table_name);
if (pref_value != NULL) {
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
prefs_remove_decode_as_value(pref_value, GPOINTER_TO_UINT(value_ptr), TRUE);
}
}
@ -720,7 +720,7 @@ decode_simple (GtkWidget *notebook_pg)
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle)));
pref_value = prefs_find_preference(module, table_name);
if (pref_value != NULL) {
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
prefs_add_decode_as_value(pref_value, GPOINTER_TO_UINT(value_ptr), FALSE);
}
}
@ -731,7 +731,7 @@ decode_simple (GtkWidget *notebook_pg)
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(temp_handle)));
pref_value = prefs_find_preference(module, table_name);
if (pref_value != NULL) {
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
prefs_remove_decode_as_value(pref_value, GPOINTER_TO_UINT(value_ptr), FALSE);
}
}

View File

@ -4670,7 +4670,7 @@ menu_prefs_toggle_bool (GtkWidget *w, gpointer data)
pref_t *pref = (pref_t*)data;
module_t *module = (module_t *)g_object_get_data (G_OBJECT(w), "module");
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref);
prefs_invert_bool_value(pref, pref_current);
prefs_apply (module);
@ -4692,7 +4692,7 @@ menu_prefs_change_enum (GtkWidget *w, gpointer data)
return;
if (prefs_set_enum_value(pref, new_value, pref_current)) {
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref);
prefs_apply (module);
if (!prefs.gui_use_pref_save) {
@ -4729,13 +4729,13 @@ menu_prefs_change_ok (GtkWidget *w, gpointer parent_w)
new_value);
return;
}
module->prefs_changed |= prefs_set_uint_value(pref, uval, pref_current);
module->prefs_changed_flags |= prefs_set_uint_value(pref, uval, pref_current);
break;
case PREF_STRING:
module->prefs_changed |= prefs_set_string_value(pref, new_value, pref_current);
module->prefs_changed_flags |= prefs_set_string_value(pref, new_value, pref_current);
break;
case PREF_RANGE:
if (!prefs_set_range_value_work(pref, new_value, TRUE, &module->prefs_changed)) {
if (!prefs_set_range_value_work(pref, new_value, TRUE, &module->prefs_changed_flags)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"The value \"%s\" isn't a valid range.",
new_value);
@ -4747,7 +4747,7 @@ menu_prefs_change_ok (GtkWidget *w, gpointer parent_w)
break;
}
if (module->prefs_changed) {
if (module->prefs_changed_flags) {
/* Ensure we reload the sub menu */
menu_prefs_reset();
prefs_apply (module);
@ -5415,7 +5415,8 @@ void plugin_if_menubar_preference(GHashTable *dataSet)
g_hash_table_lookup_extended(dataSet, "pref_key", NULL, (void**)&pref_name ) &&
g_hash_table_lookup_extended(dataSet, "pref_value", NULL, (void**)&pref_value ) )
{
if ( prefs_store_ext(module_name, pref_name, pref_value) )
unsigned int changed_flags = prefs_store_ext(module_name, pref_name, pref_value);
if ( changed_flags )
{
redissect_packets();
redissect_all_packet_windows();

View File

@ -1074,12 +1074,12 @@ pref_fetch(pref_t *pref, gpointer user_data)
if (p == value || *p != '\0')
return PREFS_SET_SYNTAX_ERR; /* number was bad */
#endif
module->prefs_changed |= prefs_set_uint_value(pref, uval, pref_current);
module->prefs_changed_flags |= prefs_set_uint_value(pref, uval, pref_current);
break;
case PREF_BOOL:
bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_get_control(pref)));
module->prefs_changed |= prefs_set_bool_value(pref, bval, pref_current);
module->prefs_changed_flags |= prefs_set_bool_value(pref, bval, pref_current);
break;
case PREF_ENUM:
@ -1091,7 +1091,7 @@ pref_fetch(pref_t *pref, gpointer user_data)
prefs_get_enumvals(pref));
}
module->prefs_changed |= prefs_set_enum_value(pref, enumval, pref_current);
module->prefs_changed_flags |= prefs_set_enum_value(pref, enumval, pref_current);
break;
case PREF_STRING:
@ -1099,14 +1099,14 @@ pref_fetch(pref_t *pref, gpointer user_data)
case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
module->prefs_changed |= prefs_set_string_value(pref, str_val, pref_current);
module->prefs_changed_flags |= prefs_set_string_value(pref, str_val, pref_current);
break;
case PREF_DECODE_AS_RANGE:
{
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
module->prefs_changed |= prefs_set_stashed_range_value(pref, str_val);
module->prefs_changed_flags |= prefs_set_stashed_range_value(pref, str_val);
unstash_data.module = module;
unstash_data.handle_decode_as = TRUE;
@ -1115,7 +1115,7 @@ pref_fetch(pref_t *pref, gpointer user_data)
}
case PREF_RANGE:
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
if (!prefs_set_range_value_work(pref, str_val, TRUE, &module->prefs_changed))
if (!prefs_set_range_value_work(pref, str_val, TRUE, &module->prefs_changed_flags))
#if 0
return PREFS_SET_SYNTAX_ERR; /* range was bad */
#else
@ -1142,7 +1142,7 @@ pref_fetch(pref_t *pref, gpointer user_data)
static guint
module_prefs_fetch(module_t *module, gpointer user_data)
{
gboolean *must_redissect_p = (gboolean *)user_data;
unsigned int *must_redissect_p = (unsigned int*)user_data;
/* Ignore any preferences with their own interface */
if (!module->use_gui) {
@ -1151,14 +1151,13 @@ module_prefs_fetch(module_t *module, gpointer user_data)
/* For all preferences in this module, fetch its value from this
module's notebook page. Find out whether any of them changed. */
module->prefs_changed = FALSE; /* assume none of them changed */
module->prefs_changed_flags = 0; /* assume none of them changed */
prefs_pref_foreach(module, pref_fetch, module);
/* If any of them changed, indicate that we must redissect and refilter
the current capture (if we have one), as the preference change
could cause packets to be dissected differently. */
if (module->prefs_changed)
*must_redissect_p = TRUE;
*must_redissect_p |= module->prefs_changed_flags;
return 0; /* keep fetching module preferences */
}
@ -1249,7 +1248,7 @@ module_prefs_clean_stash(module_t *module, gpointer user_data _U_)
/* fetch all pref values from all pages */
static gboolean
prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
prefs_main_fetch_all(GtkWidget *dlg, unsigned int *must_redissect)
{
pref_t *badpref;
@ -1308,7 +1307,7 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
/* apply all pref values to the real world */
static void
prefs_main_apply_all(GtkWidget *dlg, gboolean redissect)
prefs_main_apply_all(GtkWidget *dlg, unsigned int redissect)
{
GtkWidget *save_bt;
@ -1458,7 +1457,7 @@ prefs_main_save(gpointer parent_w)
static void
prefs_main_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
{
gboolean must_redissect = FALSE;
unsigned int must_redissect = 0;
if (!prefs_main_fetch_all((GtkWidget *)parent_w, &must_redissect))
return; /* Errors in some preference setting - already reported */
@ -1499,7 +1498,7 @@ prefs_main_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
static void
prefs_main_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
{
gboolean must_redissect = FALSE;
unsigned int must_redissect = 0;
if (!prefs_main_fetch_all((GtkWidget *)parent_w, &must_redissect))
return; /* Errors in some preference setting - already reported */
@ -1529,7 +1528,7 @@ prefs_main_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
static void
prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
{
gboolean must_redissect = FALSE;
unsigned int must_redissect = 0;
if (!prefs_main_fetch_all((GtkWidget *)parent_w, &must_redissect))
return; /* Errors in some preference setting - already reported */
@ -1566,7 +1565,7 @@ prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
static guint
module_prefs_revert(module_t *module, gpointer user_data)
{
gboolean *must_redissect_p = (gboolean *)user_data;
unsigned int *must_redissect_p = (unsigned int*)user_data;
pref_unstash_data_t unstashed_data;
/* Ignore any preferences with their own interface */
@ -1577,7 +1576,7 @@ module_prefs_revert(module_t *module, gpointer user_data)
/* For all preferences in this module, revert its value to the value
it had when we popped up the Preferences dialog. Find out whether
this changes any of them. */
module->prefs_changed = FALSE; /* assume none of them changed */
module->prefs_changed_flags = 0; /* assume none of them changed */
unstashed_data.module = module;
unstashed_data.handle_decode_as = FALSE;
prefs_pref_foreach(module, pref_unstash, &unstashed_data);
@ -1585,8 +1584,8 @@ module_prefs_revert(module_t *module, gpointer user_data)
/* If any of them changed, indicate that we must redissect and refilter
the current capture (if we have one), as the preference change
could cause packets to be dissected differently. */
if (module->prefs_changed)
*must_redissect_p = TRUE;
*must_redissect_p |= module->prefs_changed_flags;
return 0; /* keep processing modules */
}
@ -1594,7 +1593,7 @@ module_prefs_revert(module_t *module, gpointer user_data)
static void
prefs_main_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
{
gboolean must_redissect = FALSE;
unsigned int must_redissect = 0;
/* Free up the current preferences and copy the saved preferences to the
current preferences. */

View File

@ -498,7 +498,7 @@ font_color_prefs_fetch(GtkWidget *w _U_)
void
font_color_prefs_apply(GtkWidget *w _U_, gboolean redissect)
font_color_prefs_apply(GtkWidget *w _U_, unsigned int redissect)
{
if (font_changed) {
/* This redraws the packet bytes windows. */

View File

@ -46,7 +46,7 @@ void font_color_prefs_fetch(GtkWidget *widget);
*
* @param widget widget from font_color_prefs_show()
*/
void font_color_prefs_apply(GtkWidget *widget, gboolean);
void font_color_prefs_apply(GtkWidget *widget, unsigned int);
/** Destroy preference values from page.
*

View File

@ -70,47 +70,48 @@ prefs_main_write(void)
}
}
static gboolean
static unsigned int
prefs_store_ext_helper(const char * module_name, const char *pref_name, const char *pref_value)
{
module_t * module = NULL;
pref_t * pref = NULL;
gboolean pref_changed = TRUE;
unsigned int pref_changed = 0;
if ( ! prefs_is_registered_protocol(module_name))
return FALSE;
return 0;
module = prefs_find_module(module_name);
if ( ! module )
return FALSE;
return 0;
pref = prefs_find_preference(module, pref_name);
if (!pref)
return FALSE;
return 0;
if (prefs_get_type(pref) == PREF_STRING )
{
pref_changed = prefs_set_string_value(pref, pref_value, pref_stashed);
pref_changed |= prefs_set_string_value(pref, pref_value, pref_stashed);
if ( ! pref_changed || prefs_get_string_value(pref, pref_stashed) != 0 )
pref_changed = prefs_set_string_value(pref, pref_value, pref_current);
pref_changed |= prefs_set_string_value(pref, pref_value, pref_current);
}
return pref_changed;
}
gboolean
unsigned int
prefs_store_ext(const char * module_name, const char *pref_name, const char *pref_value)
{
if ( prefs_store_ext_helper(module_name, pref_name, pref_value) )
unsigned int changed_flags = prefs_store_ext_helper(module_name, pref_name, pref_value);
if ( changed_flags )
{
prefs_main_write();
prefs_apply_all();
prefs_to_capture_opts();
return TRUE;
return changed_flags;
}
return FALSE;
return 0;
}
gboolean

View File

@ -41,9 +41,9 @@ extern void prefs_main_write(void);
* @param key the key for the preference
* @param value the new value as string for the preference
*
* @return true if the value has been stored successfully
* @return flags of types of preferences changed, non-zero if the value has been stored successfully
*/
extern gboolean prefs_store_ext(const char * module, const char * key, const char * value);
extern unsigned int prefs_store_ext(const char * module, const char * key, const char * value);
/** Convenient function for the writing of multiple preferences, without
* explicitly having prefs_t variables.

View File

@ -125,7 +125,8 @@ static void plugin_if_mainwindow_preference(GHashTable * data_set)
g_hash_table_lookup_extended(data_set, "pref_key", NULL, (void**)&pref_name) &&
g_hash_table_lookup_extended(data_set, "pref_value", NULL, (void**)&pref_value))
{
if (prefs_store_ext(module_name, pref_name, pref_value)) {
unsigned int changed_flags = prefs_store_ext(module_name, pref_name, pref_value);
if (changed_flags) {
wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged);
wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged);
}

View File

@ -619,7 +619,7 @@ void DecodeAsModel::applyChanges()
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle)));
pref_value = prefs_find_preference(module, uint_entry.first);
if (pref_value != NULL) {
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
reset_pref(pref_value);
}
}
@ -688,7 +688,7 @@ void DecodeAsModel::applyChanges()
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(item->dissector_handle_)));
pref_value = prefs_find_preference(module, decode_as_entry->table_name);
if (pref_value != NULL) {
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
prefs_remove_decode_as_value(pref_value, item->selectorUint_, TRUE);
}
}
@ -703,7 +703,7 @@ void DecodeAsModel::applyChanges()
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(item->dissector_handle_)));
pref_value = prefs_find_preference(module, decode_as_entry->table_name);
if (pref_value != NULL) {
module->prefs_changed = TRUE;
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
prefs_add_decode_as_value(pref_value, item->selectorUint_, FALSE);
}
}

View File

@ -194,7 +194,7 @@ void PreferenceEditorFrame::on_preferenceLineEdit_returnPressed()
void PreferenceEditorFrame::on_buttonBox_accepted()
{
bool apply = false;
unsigned int apply = 0;
switch(prefs_get_type(pref_)) {
case PREF_UINT:
case PREF_DECODE_AS_UINT:

View File

@ -33,7 +33,7 @@ module_prefs_unstash(module_t *module, gpointer data)
unstashed_data.handle_decode_as = TRUE;
module->prefs_changed = FALSE; /* assume none of them changed */
module->prefs_changed_flags = 0; /* assume none of them changed */
for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = g_list_next(pref_l)) {
pref_t *pref = (pref_t *) pref_l->data;
@ -46,8 +46,7 @@ module_prefs_unstash(module_t *module, gpointer data)
/* If any of them changed, indicate that we must redissect and refilter
the current capture (if we have one), as the preference change
could cause packets to be dissected differently. */
if (module->prefs_changed)
*must_redissect_p = TRUE;
*must_redissect_p |= module->prefs_changed_flags;
if(prefs_module_has_submodules(module))
return prefs_modules_foreach_submodules(module, module_prefs_unstash, data);
@ -202,7 +201,7 @@ void PreferencesDialog::on_advancedSearchLineEdit_textEdited(const QString &sear
void PreferencesDialog::on_buttonBox_accepted()
{
gchar* err = NULL;
gboolean must_redissect = FALSE;
unsigned int must_redissect = 0;
QVector<unsigned> old_layout = QVector<unsigned>() << prefs.gui_layout_type
<< prefs.gui_layout_content_1
@ -213,7 +212,7 @@ void PreferencesDialog::on_buttonBox_accepted()
// XXX - We're also too enthusiastic about setting must_redissect.
// if (!prefs_main_fetch_all(parent_w, &must_redissect))
// return; /* Errors in some preference setting - already reported */
prefs_modules_foreach_submodules(NULL, module_prefs_unstash, (gpointer) &must_redissect);
prefs_modules_foreach_submodules(NULL, module_prefs_unstash, (gpointer)&must_redissect);
QVector<unsigned> new_layout = QVector<unsigned>() << prefs.gui_layout_type
<< prefs.gui_layout_content_1

View File

@ -42,8 +42,8 @@ public:
setChecked(prefs_get_bool_value(pref_, pref_current));
}
void setBoolValue() {
prefs_set_bool_value(pref_, isChecked(), pref_current);
unsigned int setBoolValue() {
return prefs_set_bool_value(pref_, isChecked(), pref_current);
}
private:
@ -63,7 +63,7 @@ public:
setCheckable(true);
}
bool setEnumValue() {
unsigned int setEnumValue() {
return prefs_set_enum_value(pref_, enumval_, pref_current);
}
@ -269,8 +269,7 @@ void ProtocolPreferencesMenu::boolPreferenceTriggered()
BoolPreferenceAction *bpa = static_cast<BoolPreferenceAction *>(QObject::sender());
if (!bpa) return;
bpa->setBoolValue();
module_->prefs_changed = TRUE;
module_->prefs_changed_flags |= bpa->setBoolValue();
prefs_apply(module_);
if (!prefs.gui_use_pref_save) {
@ -285,8 +284,9 @@ void ProtocolPreferencesMenu::enumPreferenceTriggered()
EnumPreferenceAction *epa = static_cast<EnumPreferenceAction *>(QObject::sender());
if (!epa) return;
if (epa->setEnumValue()) { // Changed
module_->prefs_changed = TRUE;
unsigned int changed_flags = epa->setEnumValue();
if (changed_flags) { // Changed
module_->prefs_changed_flags |= changed_flags;
prefs_apply(module_);
if (!prefs.gui_use_pref_save) {
prefs_main_write();