[Gnucash-changes] r13713 - gnucash/trunk - Work around the fact that a validating XML parser barfs on gnucash's

David Hampton hampton at cvs.gnucash.org
Thu Mar 30 12:20:31 EST 2006


Author: hampton
Date: 2006-03-30 12:20:29 -0500 (Thu, 30 Mar 2006)
New Revision: 13713
Trac: http://svn.gnucash.org/trac/changeset/13713

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/backend/file/io-gncxml-v2.c
   gnucash/trunk/src/gnome-utils/gnc-main-window.c
   gnucash/trunk/src/gnome-utils/gnc-window.c
Log:
Work around the fact that a validating XML parser barfs on gnucash's
use of an attribute in an undefined namespace.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-30 15:14:24 UTC (rev 13712)
+++ gnucash/trunk/ChangeLog	2006-03-30 17:20:29 UTC (rev 13713)
@@ -1,3 +1,11 @@
+2006-03-30  David Hampton  <hampton at employees.org>
+
+	* src/backend/file/io-gncxml-v2.c:
+	* src/gnome-utils/gnc-main-window.c:
+	* src/gnome-utils/gnc-window.c: Work around the fact that a
+	validating XML parser barfs on gnucash's use of an attribute in an
+	undefined namespace.
+
 2006-03-30  Joshua Sled  <jsled at asynchronous.org>
 
 	* accounts/C/acctchrt_checkbook.gnucash-xea: Revoke placeholder

Modified: gnucash/trunk/src/backend/file/io-gncxml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/io-gncxml-v2.c	2006-03-30 15:14:24 UTC (rev 13712)
+++ gnucash/trunk/src/backend/file/io-gncxml-v2.c	2006-03-30 17:20:29 UTC (rev 13713)
@@ -347,6 +347,10 @@
     
     g_return_val_if_fail(tree, FALSE);
 
+    /* Note: BADXML.
+     *
+     * This is invalid xml because the namespace isn't declared in the
+     * tag itself. This should be changed to 'type' at some point. */
     type = (char*)xmlGetProp(tree, BAD_CAST "cd:type");
     strval = dom_tree_to_text(tree);
     if(!string_to_gint64(strval, &val))
@@ -396,7 +400,13 @@
       {
         PERR("Unknown type: %s", type ? type : "(null)");
         xmlFree (type);
-        return FALSE;
+	/* Do *NOT* flag this as an error. Gnucash 1.8 writes invalid
+	 * xml by writing the 'cd:type' attribute without providing
+	 * the namespace in the gnc:count-data tag.  The parser is
+	 * entirely within its rights to refuse to read this bad
+	 * attribute. Gnucash will function correctly without the data
+	 * in this tag, so just let the error pass. */
+        return TRUE;
       }
     }
 
@@ -446,25 +456,26 @@
     total = counter->transactions_total + counter->accounts_total +
       counter->books_total + counter->commodities_total +
       counter->schedXactions_total + counter->budgets_total;
+    if (total == 0)
+      total = 1;
 
     percentage = (loaded * 100)/total;
     if (percentage > 100) {
       /* FIXME: Perhaps the below should be replaced by:
 	 print_counter_data(counter); */
-      printf("Transactions: Total: %d, Loaded: %d\n",
-             counter->transactions_total, counter->transactions_loaded);
-      printf("Accounts: Total: %d, Loaded: %d\n",
-             counter->accounts_total, counter->accounts_loaded);
-      printf("Books: Total: %d, Loaded: %d\n",
-             counter->books_total, counter->books_loaded);
-      printf("Commodities: Total: %d, Loaded: %d\n",
-             counter->commodities_total, counter->commodities_loaded);
-      printf("Scheduled Tansactions: Total: %d, Loaded: %d\n",
-             counter->schedXactions_total, counter->schedXactions_loaded);
-      printf("Budgets: Total: %d, Loaded: %d\n",
-	     counter->budgets_total, counter->budgets_loaded);
+//      printf("Transactions: Total: %d, Loaded: %d\n",
+//             counter->transactions_total, counter->transactions_loaded);
+//      printf("Accounts: Total: %d, Loaded: %d\n",
+//             counter->accounts_total, counter->accounts_loaded);
+//      printf("Books: Total: %d, Loaded: %d\n",
+//             counter->books_total, counter->books_loaded);
+//      printf("Commodities: Total: %d, Loaded: %d\n",
+//             counter->commodities_total, counter->commodities_loaded);
+//      printf("Scheduled Tansactions: Total: %d, Loaded: %d\n",
+//             counter->schedXactions_total, counter->schedXactions_loaded);
+//      printf("Budgets: Total: %d, Loaded: %d\n",
+//	     counter->budgets_total, counter->budgets_loaded);
     }
-    percentage = MIN(percentage, 100);
     gd->gui_display_fn(NULL, percentage);
 }
 
@@ -777,6 +788,11 @@
             val = g_strdup_printf("%d", amount);
 
             node = xmlNewNode(NULL, BAD_CAST COUNT_DATA_TAG);
+	    /* Note: BADXML.
+	     *
+	     * This is invalid xml because the namespace isn't
+	     * declared in the tag itself. This should be changed to
+	     * 'type' at some point. */
             xmlSetProp(node, BAD_CAST "cd:type", BAD_CAST type);
             xmlNodeAddContent(node, BAD_CAST val);
 

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c	2006-03-30 15:14:24 UTC (rev 13712)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c	2006-03-30 17:20:29 UTC (rev 13713)
@@ -2591,6 +2591,8 @@
 	gtk_widget_show (priv->progressbar);
 	gtk_box_pack_start (GTK_BOX (priv->statusbar), priv->progressbar,
 			    FALSE, TRUE, 0);
+	gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(priv->progressbar),
+					0.01);
 
 	window->ui_merge = gtk_ui_manager_new ();
 

Modified: gnucash/trunk/src/gnome-utils/gnc-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-window.c	2006-03-30 15:14:24 UTC (rev 13712)
+++ gnucash/trunk/src/gnome-utils/gnc-window.c	2006-03-30 17:20:29 UTC (rev 13713)
@@ -179,7 +179,11 @@
   } else {
     if (message)
       gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbar), message);
-    gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), percentage/100);
+    if (percentage <= 100) {
+      gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), percentage/100);
+    } else {
+      gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressbar));
+    }
   }
 
   /* make sure new text is up */



More information about the gnucash-changes mailing list