when creating new file.
Reverts the fix for https://bugs.gnucash.org/show_bug.cgi?id=726891. The
underlying problem, that a new SQL database needed to be loaded to force
its creation, is no longer a problem. It was probably corrected as part
of the C++ rewrite of the SQL backend.
It's extremely out of date and we no longer use it to keep track
of our design decisions and suggestions.
Only a section on KVP policy has been move into kvp_doc.txt
as it may make sense there.
gnc_get_match_commodity_splits needs to scan the account splitlists to
find suitable splits upto end_date. Because splitlist is date-sorted,
use gnc_account_foreach_split_until_date to avoid scanning later
splits.
The scheme version is very inefficient: (1) it uses QofQuery to
retrieve all splits, and QofQuery is slow. (2) The whole splitlist
typically is thousands splits long needs to be converted from C to
guile via consing and reverse. (3) The scheme list is immediately
filtered to select "interesting" splits only.
This function performs all of the above using Account's efficient
methods, selecting only interesting splits into a GList. This list is
then converted to scheme via cons and reverse.
The QofQuery param_list is a GSList of const char*. Every SCM Query
would typically leak the GSList. This change will store the params
into the string cache, and the cached string is passed onto the
QofQuery param.
pass -DLEAKS=ON or -DODR=ON to enable these features. They have an
effect only with CMAKE_BUILD_TYPE=Asan and don't work on Apple because
Apple clang doesn't enable them.
xaccSplitComputeCapGains creates gains_split pointers in both the Cap Gains Split and its Income split to the original split, but the original's gains_split pointer can point to only one of them, the Cap Gains split. When the original split is freed both the Cap Gains split's and its Income split need their gains_split pointers NULLed or when it's the Income split's turn to be freed it will try to deref the dangling pointer.
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.