summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/gtk/profile_dlg.c10
-rw-r--r--ui/profile.c14
-rw-r--r--ui/qt/profile_dialog.cpp1
3 files changed, 15 insertions, 10 deletions
diff --git a/ui/gtk/profile_dlg.c b/ui/gtk/profile_dlg.c
index f66f13be2d..43a3fdc9eb 100644
--- a/ui/gtk/profile_dlg.c
+++ b/ui/gtk/profile_dlg.c
@@ -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;
}
diff --git a/ui/profile.c b/ui/profile.c
index 0aed43e06f..62b46517ec 100644
--- a/ui/profile.c
+++ b/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;
diff --git a/ui/qt/profile_dialog.cpp b/ui/qt/profile_dialog.cpp
index 2d5ab8bca7..9c11291481 100644
--- a/ui/qt/profile_dialog.cpp
+++ b/ui/qt/profile_dialog.cpp
@@ -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;
}