Always update the display filter when changing a display filter macro

and when changing profile.  Not sure why I have to invalidate cfile.dfilter
in macro_update(), because this will be done in macros_post_update(),
but unless this we get a crash when renaming a macro...

This is a fix for bug 5002.

svn path=/trunk/; revision=34011
This commit is contained in:
Stig Bjørlykke 2010-08-30 08:47:26 +00:00
parent 4f6e546d4d
commit 835a43312f
4 changed files with 29 additions and 6 deletions

View File

@ -31,6 +31,7 @@
#include <ctype.h>
#include <string.h>
#include "globals.h"
#include "dfilter-int.h"
#include "dfilter.h"
#include "dfilter-macro.h"
@ -410,6 +411,10 @@ static void macro_update(void* mp, const gchar** error) {
}
}
/* Invalidate the display filter in case it's in use */
g_free (cfile.dfilter);
cfile.dfilter = NULL;
parts = g_ptr_array_new();
args_pos = g_array_new(FALSE,FALSE,sizeof(int));
@ -609,7 +614,7 @@ void dfilter_macro_init(void) {
macro_copy,
macro_update,
macro_free,
NULL,
NULL, /* Note: This is set in macros_init () */
uat_fields);
fvt_cache = g_hash_table_new(g_str_hash,g_str_equal);

View File

@ -29,14 +29,28 @@
#include <gtk/gtk.h>
#include <epan/dfilter/dfilter-macro.h>
#include <epan/uat.h>
#include <epan/uat-int.h>
#include "globals.h"
#include "gtk/uat_gui.h"
#include "gtk/macros_dlg.h"
#include "gtk/gtkglobals.h"
void macros_dialog_cb(GtkWidget *w _U_, gpointer data _U_) {
void* dfmuat;
dfilter_macro_get_uat(&dfmuat);
uat_window_cb(NULL,dfmuat);
static void macros_post_update(void) {
g_free (cfile.dfilter);
cfile.dfilter = NULL;
g_signal_emit_by_name(main_display_filter_widget, "changed");
}
void macros_init (void) {
void* dfmuat;
dfilter_macro_get_uat(&dfmuat);
((uat_t*)dfmuat)->post_update_cb = macros_post_update;
}
void macros_dialog_cb(GtkWidget *w _U_, gpointer data _U_) {
void* dfmuat;
dfilter_macro_get_uat(&dfmuat);
uat_window_cb(NULL,dfmuat);
}

View File

@ -24,6 +24,7 @@
#ifndef __MACROS_DLG_H__
#define __MACROS_DLG_H__
void macros_init (void);
void macros_dialog_cb(GtkWidget*, gpointer);
#endif /* __MACROS_DLG_H__ */

View File

@ -135,6 +135,7 @@
#include "gtk/main_airpcap_toolbar.h"
#include "gtk/main_filter_toolbar.h"
#include "gtk/menus.h"
#include "gtk/macros_dlg.h"
#include "gtk/main_packet_list.h"
#include "gtk/main_statusbar.h"
#include "gtk/main_statusbar_private.h"
@ -2828,6 +2829,8 @@ main(int argc, char *argv[])
font_init();
macros_init();
stock_icons_init();
/* close the splash screen, as we are going to open the main window now */