Always update the display filter when changing a display filter macro
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 30 Aug 2010 08:47:26 +0000 (08:47 +0000)
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 30 Aug 2010 08:47:26 +0000 (08:47 +0000)
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.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@34011 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dfilter/dfilter-macro.c
gtk/macros_dlg.c
gtk/macros_dlg.h
gtk/main.c

index 25a3b6d1367c6e2a05ea0984d4cc1f2fbb9c9e7a..07fe509aac69963724d6c6e2be085edd26ef84b9 100644 (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);
index ae99b72d09651af296c8ca3bb2d96ff9c797dc6e..2a1b4d2205c095fafdb52fb0bf0d62d7b05ea44a 100644 (file)
 #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"
+
+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);
+       void* dfmuat;
+       dfilter_macro_get_uat(&dfmuat);
+       uat_window_cb(NULL,dfmuat);
 }
 
index 52890aee3250e55037ab47a35164a346e31ec827..24e420ea50be0182b67cceed4c3e9e05fdaa3773 100644 (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__ */
index d4d70df0de3e42e3c154cb807c03de8d4d73d4f1..f80ca3538f591ce471ec4533769b64955db94f53 100644 (file)
 #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 */