Derek Atkins wrote:

What's the point of the global, static fb_info?  In general static
storage is a Bad Idea (TM).

Agreed. It's something I copied from 1.8.12, and didn't spend enough time thinking if the global was necessary. It is the storage space where the callback function (for when OK is clicked) stores the filename. I see that given the lifetime of the dialog box that local storage (in gnc_file_dialog) would have sufficed.

I have attached another patch (to be applied after the previous one). This is also in the gda-dev branch. This changes the global fb_info to a local variable in gnc_file_dialog. Its lifetime exceeds that of the dialog which uses it. I tried this code, and successfully opened a file, so the communication between the callback and gnc_file_dialog still works.

Thanks, Derek,
Mark


As for the QSF Importer -- I'm not at all surprised that it doesn't
use the GnuCash APIs :(   Feel free to change that ;)

I might (can't say won't after this one :-), but I am mainly interested in getting a database backend.


-derek


--- gda-dev/src/gnome-utils/gnc-file.c  2006-12-24 14:20:02.000000000 -0700
+++ mj-dev/src/gnome-utils/gnc-file.c   2006-12-24 14:20:56.000000000 -0700
@@ -62,9 +62,6 @@
   char *file_name;
 } FileBoxInfo;
 
-/* Global filebox information */
-static FileBoxInfo fb_info = {NULL, NULL};
-
 /* PROTOTYPES *******************************************************/
 static void store_filename (GtkWidget *w, gpointer data);
 
@@ -91,10 +88,11 @@
                 )
 {
   ENTER("\n");
+  /* filebox information */
+  /* This can be allocated on the stack so long as the lifetime
+  ** of the dialog is limited to this function. */
+  FileBoxInfo fb_info = {NULL, NULL};
 
-  if (fb_info.file_name != NULL)
-    g_free(fb_info.file_name);
-  fb_info.file_name = NULL;
 
   /* Create the dialog */
   fb_info.file_box = GTK_FILE_SELECTION(gtk_file_selection_new(title));
_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to