From 1e36965ded173d601659bb1037468ad51d685c7d Mon Sep 17 00:00:00 2001 From: Joshua Sled Date: Fri, 6 Jul 2001 08:29:36 +0000 Subject: [PATCH] Don't write section unless there is data to write [1.6/1.7 interop-issue brought up on #gnucash]. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4907 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/io-gncxml-v2.c | 27 +++++++++++++++++++++------ src/gnome/dialog-sxsincelast.c | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/engine/io-gncxml-v2.c b/src/engine/io-gncxml-v2.c index 25cab9a12a..8d56ab7bcf 100644 --- a/src/engine/io-gncxml-v2.c +++ b/src/engine/io-gncxml-v2.c @@ -564,12 +564,27 @@ write_transactions(FILE *out, GNCBook *book) static void write_template_transaction_data( FILE *out, GNCBook *book ) { - fprintf( out, "<%s>\n", TEMPLATE_TRANSACTION_TAG ); - write_account_group( out, gnc_book_get_template_group(book) ); - xaccGroupForEachTransaction( gnc_book_get_template_group(book), - xml_add_trn_data, - (gpointer)out ); - fprintf( out, "\n", TEMPLATE_TRANSACTION_TAG ); + AccountGroup *ag; + GList *gl; + gboolean hasTemplateTransactionData = FALSE; + + ag = gnc_book_get_template_group(book); + gl = xaccGroupGetSubAccounts( ag ); + while ( !hasTemplateTransactionData && + (gl != NULL) ) { + hasTemplateTransactionData |= + (xaccAccountGetSplitList( (Account*)gl->data ) != NULL); + gl = gl->next; + } + + if ( hasTemplateTransactionData ) { + fprintf( out, "<%s>\n", TEMPLATE_TRANSACTION_TAG ); + write_account_group( out, gnc_book_get_template_group(book) ); + xaccGroupForEachTransaction( ag, + xml_add_trn_data, + (gpointer)out ); + fprintf( out, "\n", TEMPLATE_TRANSACTION_TAG ); + } } static void diff --git a/src/gnome/dialog-sxsincelast.c b/src/gnome/dialog-sxsincelast.c index 5ee4ff7e12..1a5334504d 100644 --- a/src/gnome/dialog-sxsincelast.c +++ b/src/gnome/dialog-sxsincelast.c @@ -288,6 +288,7 @@ sxsincelast_populate( sxSinceLastData *sxsld ) if ( sxList == NULL ) { DEBUG( "No scheduled transactions to populate." ); + return; } do {