r15755 - gnucash/trunk/src/backend/file - Don't crash if an example	account file has no root account. Also
    David Hampton 
    hampton at cvs.gnucash.org
       
    Sun Mar 25 22:58:24 EDT 2007
    
    
  
Author: hampton
Date: 2007-03-25 22:58:23 -0400 (Sun, 25 Mar 2007)
New Revision: 15755
Trac: http://svn.gnucash.org/trac/changeset/15755
Modified:
   gnucash/trunk/src/backend/file/io-example-account.c
Log:
Don't crash if an example account file has no root account.  Also
filter the file names (*xea) when reading accounts directories.
Modified: gnucash/trunk/src/backend/file/io-example-account.c
===================================================================
--- gnucash/trunk/src/backend/file/io-example-account.c	2007-03-25 23:05:47 UTC (rev 15754)
+++ gnucash/trunk/src/backend/file/io-example-account.c	2007-03-26 02:58:23 UTC (rev 15755)
@@ -32,6 +32,7 @@
 #include <unistd.h>
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include "sixtp.h"
 
@@ -149,6 +150,11 @@
     }
     else if (!gnc_account_get_parent(act))
     {
+        if (!gea->root) {
+            g_warning(_("The example account file should declared a ROOT "
+                        "account before declaring any other accounts."));
+            gea->root = gnc_book_get_root_account(gea->book);
+        }
         gnc_account_append_child(gea->root, act);
     }
 }
@@ -450,6 +456,9 @@
     {
         gchar *filename;
         GncExampleAccount *gea;
+        if (!g_str_has_suffix(direntry, "xea"))
+          continue;
+
         filename = g_build_filename(dirname, direntry, (gchar*) NULL);
 
         if(!g_file_test(filename, G_FILE_TEST_IS_DIR))
    
    
More information about the gnucash-changes
mailing list