Don't mark the file as unsaved unless the capture or packet comments actually changed.
authorJeff Morriss <jeff.morriss@ulticom.com>
Fri, 23 Mar 2012 01:41:59 +0000 (01:41 -0000)
committerJeff Morriss <jeff.morriss@ulticom.com>
Fri, 23 Mar 2012 01:41:59 +0000 (01:41 -0000)
svn path=/trunk/; revision=41744

file.c
ui/gtk/edit_packet_comment_dlg.c
ui/gtk/new_packet_list.c
wiretap/wtap.c

diff --git a/file.c b/file.c
index 5d8d8e624b14c2f0172ba23ac00010fde4bbb6c6..b8692b6a2f4d765ffc3363e2b16e3e52713363e0 100644 (file)
--- a/file.c
+++ b/file.c
@@ -3658,10 +3658,9 @@ cf_unignore_frame(capture_file *cf, frame_data *frame)
 const gchar* 
 cf_read_shb_comment(capture_file *cf)
 {
-  wtapng_section_tshb_inf;
+  wtapng_section_t *shb_inf;
   const gchar *temp_str;
 
-
   /* Get info from SHB */
   shb_inf = wtap_file_get_shb_info(cf->wth);
   if(shb_inf == NULL)
@@ -3676,10 +3675,23 @@ cf_read_shb_comment(capture_file *cf)
 void
 cf_update_capture_comment(capture_file *cf, gchar *comment)
 {
+  wtapng_section_t *shb_inf;
 
   /* Get info from SHB */
-  wtap_write_shb_comment(cf->wth, comment);
+  shb_inf = wtap_file_get_shb_info(cf->wth);
 
+  /* See if the comment has changed or not */
+  if (shb_inf && shb_inf->opt_comment) {
+    if (strcmp(shb_inf->opt_comment, comment) == 0) {
+      g_free(comment);
+      return;
+    }
+  }
+
+  /* The comment has changed, let's update it */
+  wtap_write_shb_comment(cf->wth, comment);
+  /* Mark the file as unsaved */
+  cf->user_saved = FALSE;
 }
 
 typedef struct {
index 2fd7a1cc568b2c784e37600d12e2d57c73212b59..5b8cae1db3e311dd5938ac03fa6dee60865d91ce 100644 (file)
@@ -105,8 +105,7 @@ capture_comment_text_buff_ok_cb(GtkWidget *w _U_, GtkWidget *view)
   /*g_warning("The new comment is '%s'",new_capture_comment);*/
   cf_update_capture_comment(&cfile, new_capture_comment);
 
-  /* Mark the file as unsaved, caues a popup asking to save the file if we quit the file */
-  cfile.user_saved = FALSE;
+  /* Update the menus in case the file might need to be saved */
   set_menus_for_capture_file(&cfile);
 
   window_destroy(edit_or_add_capture_comment_dlg);
index f8eaf0c9183c66e0548f66c1e83216041d10e034..8a2bf50e922a6899da209b1a057eeade865cff49 100644 (file)
@@ -1733,9 +1733,20 @@ new_packet_list_update_packet_comment(gchar *new_packet_comment)
                return;
 
        record = new_packet_list_get_record(model, &iter);
+
+       /* Check if the comment has changed */
+       if (record->fdata->opt_comment) {
+               if (strcmp(record->fdata->opt_comment, new_packet_comment) == 0) {
+                       g_free(new_packet_comment);
+                       return;
+               }
+       }
+
+       /* The comment has changed, let's update it */
        g_free(record->fdata->opt_comment);
        record->fdata->opt_comment = new_packet_comment;
-       /* Mark the file as unsaved, caues a popup asking to save the file if we quit the file */
+
+       /* Mark the file as unsaved */
        cfile.user_saved = FALSE;
        set_menus_for_capture_file(&cfile);
 
index 7bdd1bf9191deaab7c278e4b10806b71c9b0cbc8..5edfed5efd71e7271114ea55ed65406d9501d585 100644 (file)
@@ -96,7 +96,8 @@ wtap_file_tsprecision(wtap *wth)
        return wth->tsprecision;
 }
 
-wtapng_section_t* wtap_file_get_shb_info(wtap *wth)
+wtapng_section_t *
+wtap_file_get_shb_info(wtap *wth)
 {
        wtapng_section_t                *shb_hdr;
 
@@ -114,21 +115,23 @@ wtapng_section_t* wtap_file_get_shb_info(wtap *wth)
        return shb_hdr;
 }
 
-void wtap_write_shb_comment(wtap *wth, gchar *comment)
+void
+wtap_write_shb_comment(wtap *wth, gchar *comment)
 {
        g_free(wth->shb_hdr.opt_comment);
        wth->shb_hdr.opt_comment = comment;
 
 }
 
-wtapng_iface_descriptions_t* wtap_file_get_idb_info(wtap *wth)
+wtapng_iface_descriptions_t *
+wtap_file_get_idb_info(wtap *wth)
 {
        wtapng_iface_descriptions_t *idb_info;
 
        idb_info = g_new(wtapng_iface_descriptions_t,1);
 
        idb_info->number_of_interfaces  = wth->number_of_interfaces;
-       idb_info->interface_data                = wth->interface_data;
+       idb_info->interface_data        = wth->interface_data;
 
        return idb_info;
 }
@@ -601,8 +604,8 @@ int wtap_register_encap_type(char* name, char* short_name) {
 
 
 /* Name that should be somewhat descriptive. */
-const char
-*wtap_encap_string(int encap)
+const char *
+wtap_encap_string(int encap)
 {
        if (encap < WTAP_ENCAP_PER_PACKET || encap >= WTAP_NUM_ENCAP_TYPES)
                return "Illegal";
@@ -613,8 +616,8 @@ const char
 }
 
 /* Name to use in, say, a command-line flag specifying the type. */
-const char
-*wtap_encap_short_string(int encap)
+const char *
+wtap_encap_short_string(int encap)
 {
        if (encap < WTAP_ENCAP_PER_PACKET || encap >= WTAP_NUM_ENCAP_TYPES)
                return "illegal";
@@ -664,8 +667,8 @@ static const char *wtap_errlist[] = {
 };
 #define        WTAP_ERRLIST_SIZE       (sizeof wtap_errlist / sizeof wtap_errlist[0])
 
-const char
-*wtap_strerror(int err)
+const char *
+wtap_strerror(int err)
 {
        static char errbuf[128];
        unsigned int wtap_errlist_index;
@@ -845,19 +848,19 @@ wtap_read_so_far(wtap *wth)
        return file_tell_raw(wth->fh);
 }
 
-struct wtap_pkthdr*
+struct wtap_pkthdr *
 wtap_phdr(wtap *wth)
 {
        return &wth->phdr;
 }
 
-union wtap_pseudo_header*
+union wtap_pseudo_header *
 wtap_pseudoheader(wtap *wth)
 {
        return &wth->pseudo_header;
 }
 
-guint8*
+guint8 *
 wtap_buf_ptr(wtap *wth)
 {
        return buffer_start_ptr(wth->frame_buffer);