gnucash master: [C++options] Fix Guile crash when restoring some reports.

John Ralls jralls at code.gnucash.org
Fri Apr 29 14:16:35 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/a8e6a59b (commit)
	from  https://github.com/Gnucash/gnucash/commit/3e109d0c (commit)



commit a8e6a59bf8ac13de5c0d5a260824a848095298db
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Apr 29 11:13:41 2022 -0700

    [C++options] Fix Guile crash when restoring some reports.
    
    In particular those with commodity options or those using a stylesheet
    whose name has spaces like "Head or Tail".

diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i
index 8f696e0f0..4dde0c060 100644
--- a/libgnucash/app-utils/gnc-optiondb.i
+++ b/libgnucash/app-utils/gnc-optiondb.i
@@ -1141,7 +1141,7 @@ inline SCM return_scm_value(ValueType value)
     SCM save_scm_value()
     {
         static const SCM plain_format_str{scm_from_utf8_string("~s")};
-        static const SCM ticked_format_str{scm_from_utf8_string("'~a")};
+        static const SCM ticked_format_str{scm_from_utf8_string("'~s")};
 //scm_simple_format needs a scheme list of arguments to match the format
 //placeholders.
         return std::visit([$self] (auto &option) -> SCM {
@@ -1185,7 +1185,7 @@ inline SCM return_scm_value(ValueType value)
                      }
                      else
                      {
-                          const SCM commodity_fmt{scm_from_utf8_string("~s ~s")};
+                          const SCM commodity_fmt{scm_from_utf8_string("'(commodity-scm ~s ~s)")};
                           auto name_space{gnc_commodity_get_namespace(comm)};
                           auto commodity_val{scm_list_2(scm_from_utf8_string(name_space),
                                                         scm_from_utf8_string(mnemonic))};
@@ -1232,7 +1232,7 @@ inline SCM return_scm_value(ValueType value)
                     }
                     else
                     {
-                        auto scm_str{scm_list_1(scm_from_utf8_string(serial.c_str()))};
+                        auto scm_str{scm_list_1(scm_string_to_symbol(scm_from_utf8_string(serial.c_str())))};
                         return scm_simple_format(SCM_BOOL_F, ticked_format_str, scm_str);
                     }
                 }
@@ -1330,15 +1330,16 @@ inline SCM return_scm_value(ValueType value)
                             return;
                         }
                         auto len{scm_to_uint(scm_length(new_value))};
-                        std::string mnemonic{scm_to_utf8_string(scm_list_ref(new_value, scm_from_uint(0)))};
                         if (len > 1)
                         {
-                             std::string name_space{scm_to_utf8_string(scm_list_ref(new_value, scm_from_uint(1)))};
-                             option.deserialize(name_space + ":" + mnemonic);
+                            auto revlist{scm_reverse(new_value)};
+                            std::string name_space{scm_to_utf8_string(scm_cadr(revlist))};
+                            std::string mnemonic{scm_to_utf8_string(scm_car(revlist))};
+                            option.deserialize(name_space + ":" + mnemonic);
                         }
                         else
                         {
-                            option.deserialize(mnemonic);
+                            option.deserialize(scm_to_utf8_string(scm_car(new_value)));
                         }
                         return;
                     }



Summary of changes:
 libgnucash/app-utils/gnc-optiondb.i | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list