Don't mark the file as unsaved unless the capture or packet comments actually changed.

svn path=/trunk/; revision=41744
This commit is contained in:
Jeff Morriss 2012-03-23 01:41:59 +00:00
parent 4efb92a274
commit 9c1bf7223e
4 changed files with 44 additions and 19 deletions

18
file.c
View File

@ -3658,10 +3658,9 @@ cf_unignore_frame(capture_file *cf, frame_data *frame)
const gchar*
cf_read_shb_comment(capture_file *cf)
{
wtapng_section_t* shb_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 {

View 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);

View 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);

View 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);