AUDIT: r17553 - gnucash/trunk/src/gnome-utils - GNCAmountEdit: Put the text through the expression parser once instead of twice. This caused a problem in locales that print negative numbers in parentheses. For example, if you entered "-4/3", after the first parse the displayed text would change to "(1 + 1/3)", meaning negative one and one-third. Parsing that text a second time changes the text to "1 + 1/3" since, to the expression parser, parentheses indicate grouping rather than sign.

Charles Day cedayiv at cvs.gnucash.org
Wed Sep 17 22:26:52 EDT 2008


Author: cedayiv
Date: 2008-09-17 22:26:51 -0400 (Wed, 17 Sep 2008)
New Revision: 17553
Trac: http://svn.gnucash.org/trac/changeset/17553

Modified:
   gnucash/trunk/src/gnome-utils/gnc-amount-edit.c
Log:
GNCAmountEdit: Put the text through the expression parser once instead of twice. This caused a problem in locales that print negative numbers in parentheses. For example, if you entered "-4/3", after the first parse the displayed text would change to "(1 + 1/3)", meaning negative one and one-third. Parsing that text a second time changes the text to "1 + 1/3" since, to the expression parser, parentheses indicate grouping rather than sign.

The reason the GNCAmountEdit was putting the text through the parser twice was that it was setting gae->need_to_parse FALSE, but then immediately calling gtk_entry_set_text(), which issues a "changed" signal. The callback for that signal was setting gae->need_to_parse back to TRUE. So I simply changed the order of the statements.
BP


Modified: gnucash/trunk/src/gnome-utils/gnc-amount-edit.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-amount-edit.c	2008-09-17 19:01:54 UTC (rev 17552)
+++ gnucash/trunk/src/gnome-utils/gnc-amount-edit.c	2008-09-18 02:26:51 UTC (rev 17553)
@@ -321,12 +321,12 @@
   g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
   g_return_if_fail(!gnc_numeric_check (amount));
 
+  /* Update the display. */
+  amount_string = xaccPrintAmount (amount, gae->print_info);
+  gtk_entry_set_text (GTK_ENTRY(gae), amount_string);
+
   gae->amount = amount;
   gae->need_to_parse = FALSE;
-
-  amount_string = xaccPrintAmount (amount, gae->print_info);
-
-  gtk_entry_set_text (GTK_ENTRY(gae), amount_string);
 }
 
 /**



More information about the gnucash-changes mailing list