forked from osmocom/wireshark
Finish off emem_strbuf_t usage.
Change-Id: Ib0b911c86a7f8a7cca022e9e324c910664ce397e Reviewed-on: https://code.wireshark.org/review/6461 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
3a9869d81a
commit
5fe1f66176
|
@ -139,6 +139,7 @@ profile_apply(GtkWidget *main_w, GtkTreeView *profile_l, gboolean destroy)
|
|||
|
||||
if ((err_msg = apply_profile_changes()) != NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free((gchar*)err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -735,9 +736,14 @@ profile_name_edit_ok(GtkWidget *w _U_, gpointer parent_w)
|
|||
const gchar *new_name = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
const gchar *profile_name = "";
|
||||
gboolean from_global = FALSE;
|
||||
char *pf_dir_path, *pf_dir_path2, *pf_filename;
|
||||
char *pf_dir_path, *pf_dir_path2, *pf_filename, *valid_name;
|
||||
|
||||
if ((strlen(new_name) == 0) || (profile_name_is_valid(new_name) != NULL)) {
|
||||
if (strlen(new_name) == 0) {
|
||||
return;
|
||||
}
|
||||
valid_name = (char*)profile_name_is_valid(new_name);
|
||||
if (valid_name != NULL) {
|
||||
g_free(valid_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
14
ui/profile.c
14
ui/profile.c
|
@ -114,7 +114,6 @@ const gchar *apply_profile_changes(void) {
|
|||
GList *fl1, *fl2;
|
||||
profile_def *profile1, *profile2;
|
||||
gboolean found;
|
||||
emem_strbuf_t *message = ep_strbuf_new(NULL);
|
||||
const gchar *err_msg;
|
||||
|
||||
/* First validate all profile names */
|
||||
|
@ -123,8 +122,7 @@ const gchar *apply_profile_changes(void) {
|
|||
profile1 = (profile_def *) fl1->data;
|
||||
g_strstrip(profile1->name);
|
||||
if ((err_msg = profile_name_is_valid(profile1->name)) != NULL) {
|
||||
ep_strbuf_printf(message, "%s", err_msg);
|
||||
return message->str;
|
||||
return err_msg;
|
||||
}
|
||||
fl1 = g_list_next(fl1);
|
||||
}
|
||||
|
@ -136,11 +134,11 @@ const gchar *apply_profile_changes(void) {
|
|||
g_strstrip(profile1->name);
|
||||
if (profile1->status == PROF_STAT_COPY) {
|
||||
if (create_persconffile_profile(profile1->name, &pf_dir_path) == -1) {
|
||||
ep_strbuf_printf(message,
|
||||
"Can't create directory\n\"%s\":\n%s.",
|
||||
err_msg = g_strdup_printf("Can't create directory\n\"%s\":\n%s.",
|
||||
pf_dir_path, g_strerror(errno));
|
||||
|
||||
g_free(pf_dir_path);
|
||||
return err_msg;
|
||||
}
|
||||
profile1->status = PROF_STAT_EXISTS;
|
||||
|
||||
|
@ -354,7 +352,7 @@ const gchar *
|
|||
profile_name_is_valid(const gchar *name)
|
||||
{
|
||||
gchar *reason = NULL;
|
||||
emem_strbuf_t *message = ep_strbuf_new(NULL);
|
||||
gchar *message;
|
||||
|
||||
#ifdef _WIN32
|
||||
char *invalid_dir_char = "\\/:*?\"<>|";
|
||||
|
@ -383,9 +381,9 @@ profile_name_is_valid(const gchar *name)
|
|||
#endif
|
||||
|
||||
if (reason) {
|
||||
ep_strbuf_printf(message, "A profile name cannot %s\nProfiles unchanged.", reason);
|
||||
message = g_strdup_printf("A profile name cannot %s\nProfiles unchanged.", reason);
|
||||
g_free(reason);
|
||||
return message->str;
|
||||
return message;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -273,6 +273,7 @@ void ProfileDialog::on_buttonBox_accepted()
|
|||
QMessageBox::critical(this, tr("Profile Error"),
|
||||
err_msg,
|
||||
QMessageBox::Ok);
|
||||
g_free((gchar*)err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue