When adding gnc.commodity=debug to log.conf, a few problems result, which this patch attempts to fix.

A few functions (gnc_quote_source_get_type, gnc_quote_source_get_index, gnc_quote_source_get_supported) called the ENTER macro when starting but called the DEBUG macro when returning. Because these ENTER calls had no matching LEAVE, the indentation in the log file would become messed up. This patch fixes that problem by changing those DEBUG macros to LEAVE macros.

More seriously, gnucash would crash when editing a commodity whose quote source timezone is set to local time. In that case gnc_commodity_set_quote_tz is called with a NULL tz parameter. However, the ENTER macro would always attempt to dereference tz to print it, resulting a crash. This patch fixes that problem changing the macro to use the string "(null)" in the case that tz is NULL.

I have not yet filed bugs on these issues. If that would be helpful I can do so.

Daniel Harding
Index: engine/gnc-commodity.c
===================================================================
--- engine/gnc-commodity.c      (revision 16596)
+++ engine/gnc-commodity.c      (working copy)
@@ -377,7 +377,7 @@
     return SOURCE_SINGLE;
   }
 
-  DEBUG("type is %d",source->type);
+  LEAVE("type is %d",source->type);
   return source->type;
 }
 
@@ -390,7 +390,7 @@
     return 0;
   }
 
-  DEBUG("index is %d", source->index);
+  LEAVE("index is %d", source->index);
   return source->index;
 }
 
@@ -403,7 +403,7 @@
     return FALSE;
   }
 
-  DEBUG("%ssupported", source && source->supported ? "" : "not ");
+  LEAVE("%ssupported", source && source->supported ? "" : "not ");
   return source->supported;
 }
 
@@ -969,7 +969,7 @@
 void
 gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz) 
 {
-  ENTER ("(cm=%p, tz=%s)", cm, tz);
+  ENTER ("(cm=%p, tz=%s)", cm, tz ? tz : "(null)");
 
   if(!cm || tz == cm->quote_tz) return;
 
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to