Clear the filter expression list in prefs.c.

Move filter_expression_nuke from ui/gtk to epan and rename it to
filter_expression_free. Call it in prefs_reset along with the other
preference reset routines.

This keeps the Qt filter toolbar from filling up with duplicate
expressions when the profile changes.

Change-Id: I9fae9a7b48944079ea342a126979d9e79af0d22b
Reviewed-on: https://code.wireshark.org/review/7281
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2015-02-20 13:44:27 -08:00
parent 422ad100aa
commit ead79e6aa1
6 changed files with 39 additions and 13 deletions

View File

@ -499,6 +499,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
fc_fc4_val@Base 1.9.1
fetch_tapped_data@Base 1.9.1
filter_expression_new@Base 1.9.1
filter_expression_free@Base 1.99.3
find_and_mark_frame_depended_upon@Base 1.12.0~rc1
find_circuit@Base 1.9.1
find_color_conversation_filter@Base 1.99.2

View File

@ -76,6 +76,18 @@ filter_expression_init(gboolean enable_prefs)
prefs.filter_expressions = pfilter_expression_head;
}
void
filter_expression_free(struct filter_expression *list_head)
{
if (list_head == NULL)
return;
filter_expression_free(list_head->next);
g_free(list_head->label);
g_free(list_head->expression);
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*

View File

@ -29,6 +29,10 @@
extern "C" {
#endif /* __cplusplus */
/** @file
* Filter expressions.
*/
struct filter_expression {
gpointer button; /* Filter toolbar */
gchar *label;
@ -43,12 +47,25 @@ struct filter_expression {
WS_DLL_PUBLIC struct filter_expression **pfilter_expression_head;
/** Create a filter expression
*
* @param label Label (button) text for the expression.
* @param expr The display filter for the expression.
* @param enabled Determines if the expression is shown in the UI.
* @return A newly allocated and initialized struct filter_expression.
*/
WS_DLL_PUBLIC
struct filter_expression *filter_expression_new(const gchar *label,
const gchar *expr, const gboolean enabled);
void filter_expression_init(gboolean prefs);
/** Clear the filter expression list.
* Frees each item in the list. Caller should set list_head to NULL afterward.
*/
WS_DLL_PUBLIC
void filter_expression_free(struct filter_expression *list_head);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -3124,6 +3124,13 @@ prefs_reset(void)
*/
oids_cleanup();
/*
* Free the filter expression list.
*/
filter_expression_free(*pfilter_expression_head);
*pfilter_expression_head = NULL;
/*
* Reset the non-dissector preferences.
*/

View File

@ -87,16 +87,6 @@ filter_expression_save_dlg_init(gpointer filter_tb, gpointer filter_te)
}
}
static void
filter_expression_nuke(struct filter_expression *fe)
{
if (fe == NULL)
return;
filter_expression_nuke(fe->next);
g_free(fe->label);
g_free(fe->expression);
}
void
filter_expression_reinit(int what)
{
@ -113,7 +103,7 @@ filter_expression_reinit(int what)
}
}
if (what == FILTER_EXPRESSION_REINIT_DESTROY) {
filter_expression_nuke(*pfilter_expression_head);
filter_expression_free(*pfilter_expression_head);
*pfilter_expression_head = NULL;
return;
}
@ -146,7 +136,7 @@ filter_expression_reinit(int what)
filter_expression_new(fe->label, fe->expression,
fe->enabled);
}
filter_expression_nuke(prevhead);
filter_expression_free(prevhead);
/* Create the buttons again */
fe = *pfilter_expression_head;

View File

@ -3798,7 +3798,6 @@ void change_configuration_profile (const gchar *profile_name)
/* Set profile name and update the status bar */
set_profile_name (profile_name);
profile_bar_update ();
filter_expression_reinit(FILTER_EXPRESSION_REINIT_DESTROY);
/* Reset current preferences and apply the new */
prefs_reset();