Clear the schema_hash at app shutdown via gnc_prefs_remove_registered
and make that function available to the Python bindings so that
python programs can do so too.
There is a new find module since cmake 3.12. Cmake 3.27 will start
emitting warnings if the old modules are still in use.
Current implementation supports both. As soon as we can bump our minimal
cmake version to 3.12, the old support code can be dropped as well.
save_scm_value was trying too hard to handle the different possible
types that Scheme can set options to and in the process converting
lists to single symobls (e.g. ('good 'ugly) became #{good ugly}#.
That not being one of the possible values it was ignored and the
default value was used.
==64824== 171 (88 direct, 83 indirect) bytes in 1 blocks are definitely lost in loss record 392 of 418
==64824== at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==64824== by 0x528A935: qof_session_new (qofsession.cpp:148)
==64824== by 0x141832: main (sqlite3test.c:34)
... when called from guile e.g. test-transaction and lots of other tests
- gchar will also get the char* typemap, by typedef reduction
==119964== Mismatched free() / delete / delete []
==119964== at 0x4847A1F: operator delete[](void*) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==119964== by 0x669F3E4: _wrap_gnc_print_time64(scm_unused_struct*, scm_unused_struct*) (swig-engine.cpp:38533)
...
==119948== Mismatched free() / delete / delete []
==119948== at 0x4847A1F: operator delete[](void*) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==119948== by 0x6F6B431: _wrap_qof_print_date(scm_unused_struct*) (swig-engine.cpp:39124)
...
Why this compiled is a mystery. Since empty wasn't captured it should
have raised an unused variable for the outside the lambda declaration
and an undeclared variable for the use inside. Only gcc 7 raised the
first error and nothing noticed the second.
'reversed' each time you restart.
Lists read from the front, vectors to the back, so reverse the
vector after loading it.
While we're at it reserve enough elements to hold the list.
for certain reports.
Those reports being ones using complex options, apparently because
the callbacks weren't protected from Guile's garbage collector.
So replace the anyway ugly hack of a void* with a std::any wrapping
a class holding a std::unique_ptr with a custom deleter. The
constructor calls scm_gc_protect_object on the SCM containing the
callback and the custom deleter calls scm_gc_unprotect_object. The
copy constructor, required for std::any, makes a new std::unique_ptr
and calls scm_gc_protect_object again ensuring that the protect and
unprotect calls are symmetrical.
Meanwhile std::any hides the Guile dependency from all the classes
that don't need to know about it. The only ugliness is that there's
no good place to put a common implementation of SCNCallbackWrapper so it's
repeated in gnc-optiondb.i and dialog-options.cpp.
Store Number Range option values as a pair '(percentage . value) or '(pixels .
value) depending on the size of value as 4.x and earlier expect. When reading a
stored number range option handle the possibility that value is fixed
point (e.g. 50.0) as 4.x and earlier emit, avoiding a crash.
Looks like a SWIG bug, creating an extra variable that it doesn't use
bindings/python/gnucash_core.c: In function ‘_wrap_xaccAccountGetReconcileLastDate’:
bindings/python/gnucash_core.c:10096:10: warning: unused variable ‘secs20’ [-Wunused-variable]
10096 | time64 secs20 ;
| ^~~~~~
bindings/python/gnucash_core.c: In function ‘_wrap_xaccAccountGetReconcilePostponeDate’:
bindings/python/gnucash_core.c:10298:10: warning: unused variable ‘secs20’ [-Wunused-variable]
10298 | time64 secs20 ;
| ^~~~~~
bindings/python/gnucash_core.c: In function ‘_wrap_qof_query_date_predicate_get_date’:
bindings/python/gnucash_core.c:20237:10: warning: unused variable ‘secs20’ [-Wunused-variable]
20237 | time64 secs20 ;
| ^~~~~~
Instead of a gnc:split->owner, use gnc:make-split->owner instead which
generates a split->owner function with its own hashtable. This
function (and its hash table) will be garbage collected in due course,
triggering the gncOwnerFreeing of all owners.
This is a better approach than gnc:split->owner which maintains a
single hash table. It could be buggy: a report calls gnc:split->owner
to query a split, fails to reset its hashtable via #f; the split's
owner is assigned or modified, and the next call to gnc:split->owner
will return the incorrect cached owner.
Compatibility function for passing symbols or numbers as the default
value.
Note that this isn't used by GnuCash code and so isn't exercised or
tested, it's provided only to simplify user-written code migration.