r15954 - gnucash/trunk/src/register/ledger-core - Validate whether or not an account exists before calling various

David Hampton hampton at cvs.gnucash.org
Sat Apr 21 14:31:40 EDT 2007


Author: hampton
Date: 2007-04-21 14:31:39 -0400 (Sat, 21 Apr 2007)
New Revision: 15954
Trac: http://svn.gnucash.org/trac/changeset/15954

Modified:
   gnucash/trunk/src/register/ledger-core/split-register-load.c
   gnucash/trunk/src/register/ledger-core/split-register-model.c
   gnucash/trunk/src/register/ledger-core/split-register.c
Log:
Validate whether or not an account exists before calling various
functions in Account.c.



Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c	2007-04-21 18:30:20 UTC (rev 15953)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c	2007-04-21 18:31:39 UTC (rev 15954)
@@ -578,12 +578,13 @@
 static void
 gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
 {
-  Account *root;
+  Account *root = NULL;
   QuickFill *qf;
   ComboCell *cell;
   GtkListStore *store;
 
-  root = gnc_account_get_root(base_account);
+  if (base_account)
+    root = gnc_account_get_root(base_account);
   if (root == NULL)
     root = gnc_get_current_root_account();
   if (root == NULL)

Modified: gnucash/trunk/src/register/ledger-core/split-register-model.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model.c	2007-04-21 18:30:20 UTC (rev 15953)
+++ gnucash/trunk/src/register/ledger-core/split-register-model.c	2007-04-21 18:31:39 UTC (rev 15954)
@@ -1737,7 +1737,7 @@
 
     account = xaccAccountLookup (guid, gnc_get_current_book ());
 
-    name = xaccAccountGetFullName (account);
+    name = account ? xaccAccountGetFullName(account) : NULL;
   }
   else
     name = NULL;

Modified: gnucash/trunk/src/register/ledger-core/split-register.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.c	2007-04-21 18:30:20 UTC (rev 15953)
+++ gnucash/trunk/src/register/ledger-core/split-register.c	2007-04-21 18:31:39 UTC (rev 15954)
@@ -1299,6 +1299,7 @@
    Transaction *pending_trans;
    Transaction *blank_trans;
    Transaction *trans;
+   Account *account;
    Split *blank_split;
    const char *memo;
    const char *desc;
@@ -1401,8 +1402,9 @@
    /* If we are committing the blank split, add it to the account now */
    if (trans == blank_trans)
    {
-     xaccSplitSetAccount(blank_split, 
-                         gnc_split_register_get_default_account (reg));
+     account = gnc_split_register_get_default_account(reg);
+     if (account)
+       xaccSplitSetAccount(blank_split, account);
      xaccTransSetDateEnteredSecs(trans, time(NULL));
    }
 



More information about the gnucash-changes mailing list