r15593 - gnucash/branches/gda-dev/src/backend/gda - 1) Include missing header to fix compilation warning

Phil Longstaff plongstaff at cvs.gnucash.org
Sat Feb 17 23:02:49 EST 2007


Author: plongstaff
Date: 2007-02-17 23:02:48 -0500 (Sat, 17 Feb 2007)
New Revision: 15593
Trac: http://svn.gnucash.org/trac/changeset/15593

Modified:
   gnucash/branches/gda-dev/src/backend/gda/gnc-account-gda.c
   gnucash/branches/gda-dev/src/backend/gda/gnc-commodity-gda.c
Log:
1) Include missing header to fix compilation warning
2) If a new account is created from the register (by typing a new account name and responding "Yes" when asked if you want to create it), the account is created and the name is set, and then the account dialog is opened.  Setting the name forces a commit, but there is no commodity yet.  Therefore, if there is no commodity, ignore the commit.

Modified: gnucash/branches/gda-dev/src/backend/gda/gnc-account-gda.c
===================================================================
--- gnucash/branches/gda-dev/src/backend/gda/gnc-account-gda.c	2007-02-17 23:25:37 UTC (rev 15592)
+++ gnucash/branches/gda-dev/src/backend/gda/gnc-account-gda.c	2007-02-18 04:02:48 UTC (rev 15593)
@@ -197,23 +197,26 @@
 	Account* pAcc = GNC_ACCOUNT(inst);
 	const GUID* guid;
 
-	// Ensure the commodity is in the db
-	gnc_gda_save_commodity( be, xaccAccountGetCommodity( pAcc ) );
+	// If there is no commodity yet, this might be because a new account name has been entered directly
+	// into the register and an account window will be opened.  The account info is not complete yet,
+	// but the name has been set, triggering this commit
+	if( xaccAccountGetCommodity( pAcc ) != NULL ) {
+		// Ensure the commodity is in the db
+		gnc_gda_save_commodity( be, xaccAccountGetCommodity( pAcc ) );
 
-	(void)gnc_gda_do_db_operation( be,
+		(void)gnc_gda_do_db_operation( be,
 						(inst->do_free ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
 						TABLE_NAME,
 						GNC_ID_ACCOUNT, pAcc,
 						col_table );
 
-	// Delete old slot info
-	guid = qof_instance_get_guid( inst );
-
-	// Now, commit or delete any slots
-	if( !inst->do_free ) {
-		gnc_gda_slots_save( be, guid, qof_instance_get_slots( inst ) );
-	} else {
-		gnc_gda_slots_delete( be, guid );
+		// Now, commit or delete any slots
+		guid = qof_instance_get_guid( inst );
+		if( !inst->do_free ) {
+			gnc_gda_slots_save( be, guid, qof_instance_get_slots( inst ) );
+		} else {
+			gnc_gda_slots_delete( be, guid );
+		}
 	}
 }
 

Modified: gnucash/branches/gda-dev/src/backend/gda/gnc-commodity-gda.c
===================================================================
--- gnucash/branches/gda-dev/src/backend/gda/gnc-commodity-gda.c	2007-02-17 23:25:37 UTC (rev 15592)
+++ gnucash/branches/gda-dev/src/backend/gda/gnc-commodity-gda.c	2007-02-18 04:02:48 UTC (rev 15593)
@@ -40,6 +40,7 @@
 #include "gnc-commodity.h"
 
 #include "gnc-commodity-gda.h"
+#include "gnc-slots-gda.h"
 
 static QofLogModule log_module = GNC_MOD_BACKEND;
 



More information about the gnucash-changes mailing list