g_free strings allocated with gnc_prefs_get_string

gnc_prefs_get_string will return a newly-allocated string. after use,
they must be g_freed.
This commit is contained in:
Christopher Lam 2020-08-29 19:29:03 +08:00
parent de33d1ef15
commit fb42065213
3 changed files with 16 additions and 2 deletions

View File

@ -343,6 +343,7 @@ gnc_ui_file_access (GtkWindow *parent, int type)
faw->starting_dir = g_path_get_dirname( filepath );
g_free ( filepath );
}
g_free (last);
}
if (!faw->starting_dir)
faw->starting_dir = gnc_get_default_directory(settings_section);

View File

@ -256,6 +256,7 @@ gnc_history_remove_file (const char *oldfile)
}
j++;
}
g_free (filename);
}
g_free(from);
}
@ -283,12 +284,18 @@ gboolean gnc_history_test_for_file (const char *oldfile)
filename = gnc_prefs_get_string(GNC_PREFS_GROUP_HISTORY, from);
g_free(from);
if (filename && (g_utf8_collate(oldfile, filename) == 0))
if (!filename)
continue;
if (g_utf8_collate(oldfile, filename) == 0)
{
found = TRUE;
g_free (filename);
break;
}
g_free (filename);
}
return found;
}
@ -488,7 +495,7 @@ gnc_plugin_history_list_changed (gpointer prefs,
gpointer user_data)
{
GncMainWindow *window;
const gchar *filename;
gchar *filename;
gint index;
ENTER("");
@ -509,6 +516,7 @@ gnc_plugin_history_list_changed (gpointer prefs,
filename = gnc_prefs_get_string (GNC_PREFS_GROUP_HISTORY, pref);
gnc_history_update_action (window, index, filename);
g_free (filename);
gnc_main_window_actions_updated (window);
LEAVE("");

View File

@ -609,8 +609,11 @@ gnc_ui_print_restore_dialog(PrintCheckDialog *pcd)
if (guid == NULL)
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
else if (strcmp(guid, "custom") == 0)
{
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox),
pcd->format_max - 1);
g_free (guid);
}
else
{
model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
@ -622,7 +625,9 @@ gnc_ui_print_restore_dialog(PrintCheckDialog *pcd)
{
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
}
g_free (guid);
}
active = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_CHECK_POSITION);
/* If the check format used last time no longer exists, then the saved check