diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/decode_as_utils.c | 19 | ||||
-rw-r--r-- | ui/decode_as_utils.h | 2 | ||||
-rw-r--r-- | ui/gtk/decode_as_dlg.c | 8 | ||||
-rw-r--r-- | ui/qt/decode_as_dialog.cpp | 10 |
4 files changed, 26 insertions, 13 deletions
diff --git a/ui/decode_as_utils.c b/ui/decode_as_utils.c index 0d9788b36f..61a9dc174e 100644 --- a/ui/decode_as_utils.c +++ b/ui/decode_as_utils.c @@ -312,28 +312,26 @@ decode_as_write_entry (const gchar *table_name, ftenum_t selector_type, } } -void -save_decode_as_entries(void) +int +save_decode_as_entries(gchar** err) { char *pf_dir_path; char *daf_path; FILE *da_file; if (create_persconffile_dir(&pf_dir_path) == -1) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path, - g_strerror(errno)); + *err = g_strdup_printf("Can't create directory\n\"%s\"\nfor recent file: %s.", + pf_dir_path, g_strerror(errno)); g_free(pf_dir_path); - return; + return -1; } daf_path = get_persconffile_path(DECODE_AS_ENTRIES_FILE_NAME, TRUE); if ((da_file = ws_fopen(daf_path, "w")) == NULL) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Can't open decode_as_entries file\n\"%s\": %s.", daf_path, - g_strerror(errno)); + *err = g_strdup_printf("Can't open decode_as_entries file\n\"%s\": %s.", + daf_path, g_strerror(errno)); g_free(daf_path); - return; + return -1; } fputs("# \"Decode As\" entries file for Wireshark " VERSION ".\n" @@ -344,6 +342,7 @@ save_decode_as_entries(void) dissector_all_tables_foreach_changed(decode_as_write_entry, da_file); fclose(da_file); + return 0; } /* diff --git a/ui/decode_as_utils.h b/ui/decode_as_utils.h index bc00881644..a8beadef9c 100644 --- a/ui/decode_as_utils.h +++ b/ui/decode_as_utils.h @@ -41,7 +41,7 @@ void load_decode_as_entries(void); /** Write out the "decode as" entries of the current profile. */ -void save_decode_as_entries(void); +int save_decode_as_entries(gchar** err); /** This routine creates one entry in the list of protocol dissector * that need to be reset. It is called by the g_hash_table_foreach diff --git a/ui/gtk/decode_as_dlg.c b/ui/gtk/decode_as_dlg.c index 64eb232b14..382b38676a 100644 --- a/ui/gtk/decode_as_dlg.c +++ b/ui/gtk/decode_as_dlg.c @@ -441,7 +441,13 @@ decode_show_destroy_cb (GtkWidget *win _U_, gpointer user_data _U_) static void decode_show_save_cb (GtkWidget *win _U_, gpointer user_data _U_) { - save_decode_as_entries(); + gchar* err = NULL; + + if (save_decode_as_entries(&err) < 0) + { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err); + g_free(err); + } } /* add a single binding to the Show list */ diff --git a/ui/qt/decode_as_dialog.cpp b/ui/qt/decode_as_dialog.cpp index 0ba94aa556..a50f90d71a 100644 --- a/ui/qt/decode_as_dialog.cpp +++ b/ui/qt/decode_as_dialog.cpp @@ -27,6 +27,7 @@ #include "epan/epan_dissect.h" #include "ui/decode_as_utils.h" +#include "ui/simple_dialog.h" #include <wsutil/utf8_entities.h> #include "qt_ui_utils.h" @@ -640,8 +641,15 @@ void DecodeAsDialog::on_buttonBox_clicked(QAbstractButton *button) applyChanges(); break; case QDialogButtonBox::Save: + { + gchar* err = NULL; + applyChanges(); - save_decode_as_entries(); + if (save_decode_as_entries(&err) < 0) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err); + g_free(err); + } + } break; case QDialogButtonBox::Help: wsApp->helpTopicAction(HELP_DECODE_AS_SHOW_DIALOG); |