r21185 - gnucash/trunk/src - Fix crash in invoice payment introduced in commit 21181

Geert Janssens gjanssens at code.gnucash.org
Wed Aug 17 06:54:27 EDT 2011


Author: gjanssens
Date: 2011-08-17 06:54:27 -0400 (Wed, 17 Aug 2011)
New Revision: 21185
Trac: http://svn.gnucash.org/trac/changeset/21185

Modified:
   gnucash/trunk/src/engine/gncOwner.c
   gnucash/trunk/src/engine/gncOwner.h
   gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c
Log:
Fix crash in invoice payment introduced in commit 21181

Modified: gnucash/trunk/src/engine/gncOwner.c
===================================================================
--- gnucash/trunk/src/engine/gncOwner.c	2011-08-13 16:09:25 UTC (rev 21184)
+++ gnucash/trunk/src/engine/gncOwner.c	2011-08-17 10:54:27 UTC (rev 21185)
@@ -326,6 +326,16 @@
     }
 }
 
+gboolean GNC_IS_OWNER (QofInstance *ent)
+{
+    if (!ent)
+        return FALSE;
+
+    return (GNC_IS_VENDOR(ent) ||
+            GNC_IS_CUSTOMER(ent) ||
+            GNC_IS_EMPLOYEE(ent) ||
+            GNC_IS_JOB(ent));
+}
 gpointer gncOwnerGetUndefined (const GncOwner *owner)
 {
     if (!owner) return NULL;
@@ -944,7 +954,7 @@
         /* Now send an event for the invoice so it gets updated as paid */
         this_invoice = gncInvoiceGetInvoiceFromLot(lot);
         if (this_invoice)
-            qof_event_gen (QOF_INSTANCE(&this_invoice), QOF_EVENT_MODIFY, NULL);
+            qof_event_gen (QOF_INSTANCE(this_invoice), QOF_EVENT_MODIFY, NULL);
 
         if (gnc_numeric_zero_p (payment_value))
             break;

Modified: gnucash/trunk/src/engine/gncOwner.h
===================================================================
--- gnucash/trunk/src/engine/gncOwner.h	2011-08-13 16:09:25 UTC (rev 21184)
+++ gnucash/trunk/src/engine/gncOwner.h	2011-08-17 10:54:27 UTC (rev 21185)
@@ -69,6 +69,10 @@
 QofInstance* qofOwnerGetOwner (const GncOwner *owner);
 /** set the owner from the entity. */
 void qofOwnerSetEntity (GncOwner *owner, QofInstance *ent);
+/** Check if entity is an owner kind. This function conveniently
+ *  imitates the various GNC_IS_ checks on the other gnucash
+ *  objects even though an owner is not really a true object. */
+gboolean GNC_IS_OWNER (QofInstance *ent);
 
 /** Returns the QofIdType of the given GncOwnerType, or NULL if no
  * suitable one exists. */

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c	2011-08-13 16:09:25 UTC (rev 21184)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c	2011-08-17 10:54:27 UTC (rev 21185)
@@ -993,7 +993,7 @@
 
     g_return_if_fail(model);         /* Required */
 
-    if (!entity)
+    if (!GNC_IS_OWNER(entity))
         return;
 
     ENTER("entity %p of type %d, model %p, event_data %p",



More information about the gnucash-changes mailing list