gnucash unstable: Bug 794730 - SIGSEGV when entering an exchange rate, Part 2

John Ralls jralls at code.gnucash.org
Fri Mar 30 14:24:27 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/a23f103e (commit)
	from  https://github.com/Gnucash/gnucash/commit/7271ce3d (commit)



commit a23f103ebb297516b595aad26d8b7dbecde0e169
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Mar 30 11:12:04 2018 -0700

    Bug 794730 - SIGSEGV when entering an exchange rate, Part 2
    
    91f4b19 changed the test for gncInvoiceDateExists from date != 0
    to date != INT64_MAX, which isn't backwards compatible, so test
    for both. But the submitted file had a posted date of -1 so
    gncInvoiceIsPosted returned true anyway. That's not consistent with
    the logic in dialog-invoice.c, which checked gncInvoicePostedAcc != NULL,
    a better test. The result was that the "Post" button lit up but
    gncInvoicePost returned immediately, doing nothing, so change
    gncInvoiceIsPosted to use gncInvoicePostedAcc instead.

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 43c08bf..187972b 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -1799,9 +1799,10 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
         }
 
         /*
-         * Next, figure out if we've been posted, and if so set the
-         * appropriate bits of information.. Then work on hiding or
-         * showing as necessary.
+         * Next, figure out if we've been posted, and if so set the appropriate
+         * bits of information.. Then work on hiding or showing as
+         * necessary. This duplicates the logic in gncInvoiceIsPosted, but we
+         * need the accout pointer.
          */
 
         acct = gncInvoiceGetPostedAcc (invoice);
diff --git a/libgnucash/engine/gncInvoice.c b/libgnucash/engine/gncInvoice.c
index 9448ca2..6bbbd11 100644
--- a/libgnucash/engine/gncInvoice.c
+++ b/libgnucash/engine/gncInvoice.c
@@ -1858,13 +1858,16 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
 
 gboolean gncInvoiceDateExists (time64 date)
 {
-    return date != INT64_MAX;
+/* Going forward we want to use INT64_MAX to indicate "no date", but for
+ * backward compatibility we need to treat 0 as no date as well.
+ */
+    return (date != INT64_MAX && date !=0);
 }
 
 gboolean gncInvoiceIsPosted (const GncInvoice *invoice)
 {
     if (!invoice) return FALSE;
-    return gncInvoiceDateExists (invoice->date_posted);
+    return GNC_IS_ACCOUNT(gncInvoiceGetPostedAcc(invoice));
 }
 
 gboolean gncInvoiceIsPaid (const GncInvoice *invoice)



Summary of changes:
 gnucash/gnome/dialog-invoice.c | 7 ++++---
 libgnucash/engine/gncInvoice.c | 7 +++++--
 2 files changed, 9 insertions(+), 5 deletions(-)



More information about the gnucash-changes mailing list