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.
This commit is contained in:
John Ralls 2018-03-30 11:12:04 -07:00
parent 7271ce3dee
commit a23f103ebb
2 changed files with 9 additions and 5 deletions

View File

@ -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);

View File

@ -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)