[Gnucash-changes] Clean up handling of the return value from
gnc_history_get_last().
David Hampton
hampton at cvs.gnucash.org
Fri Sep 16 21:53:06 EDT 2005
Log Message:
-----------
Clean up handling of the return value from gnc_history_get_last().
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash/src/gnome-utils:
gnc-file.c
gnc-plugin-file-history.c
gw-gnome-utils-spec.scm
Revision Data
-------------
Index: gnc-file.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-file.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lsrc/gnome-utils/gnc-file.c -Lsrc/gnome-utils/gnc-file.c -u -r1.1.2.1 -r1.1.2.2
--- src/gnome-utils/gnc-file.c
+++ src/gnome-utils/gnc-file.c
@@ -661,12 +661,16 @@
gnc_file_open (void)
{
const char * newfile;
+ char *lastfile;
gboolean result;
if (!gnc_file_query_save ())
return FALSE;
- newfile = gnc_file_dialog (_("Open"), NULL, gnc_history_get_last());
+ lastfile = gnc_history_get_last();
+ newfile = gnc_file_dialog (_("Open"), NULL, lastfile);
+ if (lastfile)
+ g_free(lastfile);
result = gnc_post_file_open (newfile);
/* This dialogue can show up early in the startup process. If the
@@ -834,7 +838,7 @@
QofSession *session;
const char *filename;
char *default_dir = NULL; /* Default to last open */
- const char *last;
+ char *last;
char *newfile;
const char *oldfile;
QofBackendError io_err = ERR_BACKEND_NO_ERR;
@@ -842,10 +846,12 @@
ENTER(" ");
last = gnc_history_get_last();
- if (last)
+ if (last) {
gnc_extract_directory(&default_dir, last);
- else
+ g_free(last);
+ } else {
gnc_init_default_directory(&default_dir);
+ }
filename = gnc_file_dialog (_("Save"), "*.gnc", default_dir);
if (default_dir)
free(default_dir);
Index: gw-gnome-utils-spec.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gw-gnome-utils-spec.scm,v
retrieving revision 1.19.4.12
retrieving revision 1.19.4.13
diff -Lsrc/gnome-utils/gw-gnome-utils-spec.scm -Lsrc/gnome-utils/gw-gnome-utils-spec.scm -u -r1.19.4.12 -r1.19.4.13
--- src/gnome-utils/gw-gnome-utils-spec.scm
+++ src/gnome-utils/gw-gnome-utils-spec.scm
@@ -484,7 +484,7 @@
(gw:wrap-function
ws
'gnc:history-get-last
- '(<gw:mchars> callee-owned)
+ '(<gw:mchars> caller-owned)
"gnc_history_get_last"
'()
"Get the last file opened by the user.")
Index: gnc-plugin-file-history.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-plugin-file-history.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -Lsrc/gnome-utils/gnc-plugin-file-history.c -Lsrc/gnome-utils/gnc-plugin-file-history.c -u -r1.1.2.3 -r1.1.2.4
--- src/gnome-utils/gnc-plugin-file-history.c
+++ src/gnome-utils/gnc-plugin-file-history.c
@@ -157,18 +157,7 @@
char *
gnc_history_get_last (void)
{
- static char *filename = NULL;
- char *key;
-
- /* The static string supports the current signature of this
- * function. At some point this should be changed to pass the
- * allocated string up to the caller and make them responsible for
- * freeing irt, but that change percolates up into the scheme code
- * and requires changing that as well. */
- if (filename) {
- g_free(filename);
- filename = NULL;
- }
+ char *filename, *key;
key = g_strdup_printf(HISTORY_STRING_FILE_N, 0);
filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, key, NULL);
More information about the gnucash-changes
mailing list