gnucash master: Multiple changes pushed

Mike Alexander mta at code.gnucash.org
Fri Aug 7 20:00:58 EDT 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/1e16ba6c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/655c04bd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7e95ac28 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/82f0e286 (commit)
	from  https://github.com/Gnucash/gnucash/commit/9240c1b4 (commit)



commit 1e16ba6c14ccec6222a8fe798e7824285fd49cac
Author: Mike Alexander <mta at umich.edu>
Date:   Fri Aug 7 19:43:12 2015 -0400

    Quote the date returned by get_quote_time so Scheme can read it.

diff --git a/src/quotes/gnc-fq-helper.in b/src/quotes/gnc-fq-helper.in
index 16dd452..bbb0013 100755
--- a/src/quotes/gnc-fq-helper.in
+++ b/src/quotes/gnc-fq-helper.in
@@ -204,7 +204,7 @@ sub get_quote_time {
 
   my $datestr = $$quotehash{$item, 'date'};
   my $timestr = $$quotehash{$item, 'time'};
-  my $format = "%Y-%m-%d %H:%M:%S";
+  my $format = "\"%Y-%m-%d %H:%M:%S\"";
 
   if ($datestr) {
       my $parsestr = $datestr . " " . ($timestr ? $timestr : "12:00:00");

commit 655c04bd68d984272d8593ebbcff10f3dbaac93b
Author: Mike Alexander <mta at umich.edu>
Date:   Thu Aug 6 17:43:57 2015 -0400

    Avoid passing invalid arguments to functions to get rid of some non-fatal asserts.

diff --git a/src/app-utils/gnc-sx-instance-model.c b/src/app-utils/gnc-sx-instance-model.c
index 153554c..cd7f1a3 100644
--- a/src/app-utils/gnc-sx-instance-model.c
+++ b/src/app-utils/gnc-sx-instance-model.c
@@ -714,7 +714,8 @@ _find_unreferenced_vars(gchar *key,
                         gpointer value,
                         HashListPair *cb_pair)
 {
-    if (!g_hash_table_lookup_extended(cb_pair->hash, key, NULL, NULL))
+    if (cb_pair->hash ==  NULL ||
+        !g_hash_table_lookup_extended(cb_pair->hash, key, NULL, NULL))
     {
         g_debug("variable [%s] not found", key);
         cb_pair->list = g_list_append(cb_pair->list, key);
@@ -788,20 +789,27 @@ gnc_sx_instance_model_update_sx_instances(GncSxInstanceModel *model, SchedXactio
 
     // handle variables
     {
-        HashListPair removed_cb_data, added_cb_data;
         GList *removed_var_names = NULL, *added_var_names = NULL;
         GList *inst_iter = NULL;
 
-        removed_cb_data.hash = new_instances->variable_names;
-        removed_cb_data.list = NULL;
-        g_hash_table_foreach(existing->variable_names, (GHFunc)_find_unreferenced_vars, &removed_cb_data);
-        removed_var_names = removed_cb_data.list;
+        if (existing->variable_names != NULL)
+        {
+            HashListPair removed_cb_data;
+            removed_cb_data.hash = new_instances->variable_names;
+            removed_cb_data.list = NULL;
+            g_hash_table_foreach(existing->variable_names, (GHFunc)_find_unreferenced_vars, &removed_cb_data);
+            removed_var_names = removed_cb_data.list;
+        }
         g_debug("%d removed variables", g_list_length(removed_var_names));
 
-        added_cb_data.hash = existing->variable_names;
-        added_cb_data.list = NULL;
-        g_hash_table_foreach(new_instances->variable_names, (GHFunc)_find_unreferenced_vars, &added_cb_data);
-        added_var_names = added_cb_data.list;
+        if (new_instances->variable_names != NULL)
+        {
+            HashListPair added_cb_data;
+            added_cb_data.hash = existing->variable_names;
+            added_cb_data.list = NULL;
+            g_hash_table_foreach(new_instances->variable_names, (GHFunc)_find_unreferenced_vars, &added_cb_data);
+            added_var_names = added_cb_data.list;
+        }
         g_debug("%d added variables", g_list_length(added_var_names));
 
         if (existing->variable_names != NULL)
diff --git a/src/engine/SchedXaction.c b/src/engine/SchedXaction.c
index a1f3723..8c6292c 100644
--- a/src/engine/SchedXaction.c
+++ b/src/engine/SchedXaction.c
@@ -638,7 +638,8 @@ xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate *newEnd )
  * the SX is to run "forever". See gnc_sxed_save_sx() and
  * schedXact_editor_populate() in dialog-sx-editor.c.
  */
-    if (newEnd == NULL || g_date_compare( newEnd, &sx->start_date ) < 0 )
+    if (newEnd == NULL || 
+        (g_date_valid(newEnd) && g_date_compare( newEnd, &sx->start_date ) < 0 ))
     {
         /* XXX: I reject the bad data - is this the right
          * thing to do <rgmerk>.
diff --git a/src/register/ledger-core/split-register-model.c b/src/register/ledger-core/split-register-model.c
index 82d0f30..202958e 100644
--- a/src/register/ledger-core/split-register-model.c
+++ b/src/register/ledger-core/split-register-model.c
@@ -2093,9 +2093,12 @@ gnc_template_register_get_fdebt_entry (VirtualLocation virt_loc,
     Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
     char *formula = NULL;
 
-    qof_instance_get (QOF_INSTANCE (split),
-		      "sx-debit-formula", &formula,
-		      NULL);
+    if (split)
+    {
+        qof_instance_get (QOF_INSTANCE (split),
+                  "sx-debit-formula", &formula,
+                  NULL);
+    }
 
     return formula;
 }
@@ -2124,9 +2127,12 @@ gnc_template_register_get_fcred_entry (VirtualLocation virt_loc,
     Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
     char *formula = NULL;
 
-    qof_instance_get (QOF_INSTANCE (split),
-		      "sx-credit-formula", &formula,
-		      NULL);
+    if (split)
+    {
+        qof_instance_get (QOF_INSTANCE (split),
+                  "sx-credit-formula", &formula,
+                  NULL);
+    }
 
     return formula;
 

commit 7e95ac28a77969505b5bba5580d3e28070020102
Author: Mike Alexander <mta at umich.edu>
Date:   Thu Aug 6 01:20:23 2015 -0400

    Check for a null pointer for a credit or debit formula in gnc_sxed_check_consistent.
    
    This got dropped when qof_instance_get replaced direct KVP access and it makes
    it impossible to edit a scheduled transaction since splits can't have both a credit
    and debit value.

diff --git a/src/gnome/dialog-sx-editor.c b/src/gnome/dialog-sx-editor.c
index d4704c4..9903dae 100644
--- a/src/gnome/dialog-sx-editor.c
+++ b/src/gnome/dialog-sx-editor.c
@@ -635,7 +635,8 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
                 }
                 multi_commodity |= !gnc_commodity_equal(split_cmdty, base_cmdty);
 
-		if ( g_strcmp0 (credit_formula, "") != 0 &&
+		if ( credit_formula &&
+		     g_strcmp0 (credit_formula, "") != 0 &&
 		     gnc_sx_parse_vars_from_formula(credit_formula, vars,
 						    &tmp ) < 0 )
 		{
@@ -656,7 +657,8 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
 		    gnc_numeric_add( tcds->creditSum, tmp, 100,
 				     (GNC_DENOM_AUTO | GNC_HOW_DENOM_LCD) );
 		tmp = gnc_numeric_zero();
-		if ( g_strcmp0 (debit_formula, "") != 0 &&
+		if ( debit_formula &&
+		     g_strcmp0 (debit_formula, "") != 0 &&
 		     gnc_sx_parse_vars_from_formula( debit_formula, vars,
 						     &tmp ) < 0 )
 		{
diff --git a/src/gnome/dialog-sx-editor2.c b/src/gnome/dialog-sx-editor2.c
index 1344f44..5a57fcb 100644
--- a/src/gnome/dialog-sx-editor2.c
+++ b/src/gnome/dialog-sx-editor2.c
@@ -626,7 +626,8 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed)
                 }
                 multi_commodity |= !gnc_commodity_equal(split_cmdty, base_cmdty);
 
-		if ( g_strcmp0 (credit_formula, "") != 0 &&
+		if ( credit_formula &&
+		     g_strcmp0 (credit_formula, "") != 0 &&
 		     gnc_sx_parse_vars_from_formula(credit_formula, vars,
 						    &tmp ) < 0 )
 		{
@@ -647,7 +648,8 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed)
 		    gnc_numeric_add( tcds->creditSum, tmp, 100,
 				     (GNC_DENOM_AUTO | GNC_HOW_DENOM_LCD) );
 		tmp = gnc_numeric_zero();
-		if ( g_strcmp0 (debit_formula, "") != 0 &&
+		if ( debit_formula &&
+		     g_strcmp0 (debit_formula, "") != 0 &&
 		     gnc_sx_parse_vars_from_formula( debit_formula, vars,
 						     &tmp ) < 0 )
 		{

commit 82f0e28685829182b451c3a81ecd2657d45a0c8d
Author: Mike Alexander <mta at umich.edu>
Date:   Wed Aug 5 16:10:04 2015 -0400

    Make it possible to set variables in SX "since last run" dialog.
    
    When gnc-numeric.c was converted to C++, gnc_numeric_equal was changed so
    that an invalid number is equal to anything.  The SX since last run dialog
    initializes unset variables to invalid numbers which means that whatever you
    type is equal to what is already there and is ignored.

diff --git a/src/libqof/qof/gnc-numeric.cpp b/src/libqof/qof/gnc-numeric.cpp
index 57fdd22..d039611 100644
--- a/src/libqof/qof/gnc-numeric.cpp
+++ b/src/libqof/qof/gnc-numeric.cpp
@@ -207,6 +207,20 @@ gnc_numeric_eq(gnc_numeric a, gnc_numeric b)
 gboolean
 gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
 {
+    if (gnc_numeric_check(a))
+    {
+        /* a is not a valid number, check b */
+        if (gnc_numeric_check(b))
+            /* Both invalid, consider them equal */
+            return TRUE;
+        else
+            /* a invalid, b valid */
+            return FALSE;
+    }
+    if (gnc_numeric_check(b))
+        /* a valid, b invalid */
+        return FALSE;
+    
     return gnc_numeric_compare (a, b) == 0;
 }
 



Summary of changes:
 src/app-utils/gnc-sx-instance-model.c           | 28 ++++++++++++++++---------
 src/engine/SchedXaction.c                       |  3 ++-
 src/gnome/dialog-sx-editor.c                    |  6 ++++--
 src/gnome/dialog-sx-editor2.c                   |  6 ++++--
 src/libqof/qof/gnc-numeric.cpp                  | 14 +++++++++++++
 src/quotes/gnc-fq-helper.in                     |  2 +-
 src/register/ledger-core/split-register-model.c | 18 ++++++++++------
 7 files changed, 55 insertions(+), 22 deletions(-)



More information about the gnucash-changes mailing list