r23070 - gnucash/trunk/src - Fix the crash that occurs when duplicating multiple invoices from Find results.

Mike Alexander mta at code.gnucash.org
Sat Jun 29 01:57:36 EDT 2013


Author: mta
Date: 2013-06-29 01:57:35 -0400 (Sat, 29 Jun 2013)
New Revision: 23070
Trac: http://svn.gnucash.org/trac/changeset/23070

Modified:
   gnucash/trunk/src/business/business-gnome/dialog-invoice.c
   gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
   gnucash/trunk/src/engine/gncEntry.c
   gnucash/trunk/src/engine/gncEntry.h
   gnucash/trunk/src/engine/gncInvoice.c
Log:
Fix the crash that occurs when duplicating multiple invoices from Find results.
The biggest problem was that it was adding an invoice's entries to both the old
and the new invoice when duplicating the invoice.

Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2013-06-27 09:09:04 UTC (rev 23069)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2013-06-29 05:57:35 UTC (rev 23070)
@@ -2672,8 +2672,8 @@
         InvoiceWindow *iw = gnc_ui_invoice_duplicate(old_invoice, FALSE, &dup_user_data->date);
         // FIXME: Now we could use this invoice and manipulate further data.
         g_assert(iw);
-        new_invoice = iw->created_invoice;
-        g_assert(new_invoice); // FIXME: This is NULL?!?
+        new_invoice = iw_get_invoice(iw);
+        g_assert(new_invoice);
     }
 }
 

Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedger.c	2013-06-27 09:09:04 UTC (rev 23069)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedger.c	2013-06-29 05:57:35 UTC (rev 23070)
@@ -931,7 +931,7 @@
         GncEntry * new_entry;
 
         new_entry = gncEntryCreate (ledger->book);
-        gncEntryCopy (entry, new_entry);
+        gncEntryCopy (entry, new_entry, TRUE);
         gncEntrySetDateGDate (new_entry, &ledger->last_date_entered);
 
         /* We also must set a new DateEntered on the new entry

Modified: gnucash/trunk/src/engine/gncEntry.c
===================================================================
--- gnucash/trunk/src/engine/gncEntry.c	2013-06-27 09:09:04 UTC (rev 23069)
+++ gnucash/trunk/src/engine/gncEntry.c	2013-06-29 05:57:35 UTC (rev 23070)
@@ -797,7 +797,7 @@
     gncEntryCommitEdit (entry);
 }
 
-void gncEntryCopy (const GncEntry *src, GncEntry *dest)
+void gncEntryCopy (const GncEntry *src, GncEntry *dest, gboolean add_entry)
 {
     if (!src || !dest) return;
 
@@ -831,14 +831,17 @@
     if (src->b_tax_table)
         gncEntrySetBillTaxTable (dest, src->b_tax_table);
 
-    if (src->order)
-        gncOrderAddEntry (src->order, dest);
+    if (add_entry)
+    {
+        if (src->order)
+            gncOrderAddEntry (src->order, dest);
 
-    if (src->invoice)
-        gncInvoiceAddEntry (src->invoice, dest);
+        if (src->invoice)
+            gncInvoiceAddEntry (src->invoice, dest);
 
-    if (src->bill)
-        gncBillAddEntry (src->bill, dest);
+        if (src->bill)
+            gncBillAddEntry (src->bill, dest);
+    }
 
     dest->values_dirty = TRUE;
     gncEntryCommitEdit (dest);

Modified: gnucash/trunk/src/engine/gncEntry.h
===================================================================
--- gnucash/trunk/src/engine/gncEntry.h	2013-06-27 09:09:04 UTC (rev 23069)
+++ gnucash/trunk/src/engine/gncEntry.h	2013-06-29 05:57:35 UTC (rev 23070)
@@ -205,7 +205,7 @@
 GncEntryPaymentType gncEntryGetBillPayment (const GncEntry* entry);
 /** @} */
 
-void gncEntryCopy (const GncEntry *src, GncEntry *dest);
+void gncEntryCopy (const GncEntry *src, GncEntry *dest, gboolean add_entry);
 
 /** @name Getting Values
  *

Modified: gnucash/trunk/src/engine/gncInvoice.c
===================================================================
--- gnucash/trunk/src/engine/gncInvoice.c	2013-06-27 09:09:04 UTC (rev 23069)
+++ gnucash/trunk/src/engine/gncInvoice.c	2013-06-29 05:57:35 UTC (rev 23070)
@@ -359,7 +359,7 @@
     {
         GncEntry *from_entry = node->data;
         GncEntry *to_entry = gncEntryCreate(book);
-        gncEntryCopy(from_entry, to_entry);
+        gncEntryCopy(from_entry, to_entry, FALSE);
 
         switch (gncInvoiceGetOwnerType (invoice))
         {



More information about the gnucash-changes mailing list