Commit Graph

427 Commits

Author SHA1 Message Date
John Ralls
02e2fa0ead Bug 799308 - sqlite backend: Example Python script prints error...
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.
2024-09-05 11:53:47 -07:00
Christopher Lam
1718fa0b6e [gnc-pricedb.h] remove unused gnc_pricedb_lookup_at_time64 2024-08-31 20:45:32 +08:00
Christopher Lam
664b1cb77a [gnc-optiondb.i] instead of scm_list_ref, walk the list 2024-07-27 08:39:00 +08:00
Christopher Lam
3e5d6a510b [gnc-optiondb.i] don't add null accounts 2024-07-27 08:38:59 +08:00
John Ralls
ad7a51a6ef Merge Chris Lam's 'acc-children-vector' into stable. 2024-06-27 13:21:49 -07:00
Geert Janssens
1def3ce8fd Cleanup - remove deprecated function (re-)defines
They were deprected 11 years ago
2024-06-23 18:23:49 +02:00
Christopher Lam
d1807b6c15 [engine.i] move gnc_accounts_and_all_descendants to engine.i 2024-06-07 18:10:40 +08:00
Geert Janssens
e8d72ad53f Doxygen - merge separate txt files into respective header files 2024-05-23 15:10:05 +02:00
Geert Janssens
39aa5f9c09 Remove texi design document in engine
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.
2024-05-23 15:10:05 +02:00
Christopher Lam
4c29f69d67 [engine.i] even faster gnc_get_match_commodity_splits
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.
2024-05-02 22:21:31 +08:00
Christopher Lam
8fb5a6afd6 Fix tests so that they don't fail unnecessarily
- test-begin/test-end names must be consistent
- remove empty test group in test-scm-engine
2024-04-29 22:06:45 +08:00
Christopher Lam
68f60fef68 [engine.i] gnc_get_match_commodity_splits from scheme to c++
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.
2024-04-22 19:34:02 +08:00
Christopher Lam
cb7196a393 [base-typemaps.i] add VECTOR_HELPER_INOUT for Split* and Account*
efficiently convert std::vector<Obj> to/from guile list of objects
2024-04-22 19:34:02 +08:00
Christopher Lam
94368f4cb4 [Account.cpp] SplitsVec&, ensure xaccAccountGetSplitList is freed 2024-04-16 21:41:48 +08:00
John Ralls
e22a57ad26 Merge John Ralls's 'asan' into stable. 2023-12-08 14:56:29 -08:00
John Ralls
d92d97aef6 Add Scheme coverage collection with option GUILE_COVERAGE.
This can be used with or without COVERAGE, though if without the
results will reflect only the Scheme code exercised by the tests.
2023-12-08 14:55:49 -08:00
Christopher Lam
d8ece96503 [gnc-engine-guile.cpp] plug runaway GSList* leak
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.
2023-11-30 22:16:53 +08:00
Christopher Lam
3863d6e8dc [engine-common.i] AccountList* arg must be g_list_freed
when used by gnc_accounts_and_all_descendants
2023-11-27 21:05:06 +08:00
John Ralls
a3f14759ab Asan: Make leak and ODR violation reporting CMake options.
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.
2023-11-25 11:17:14 -08:00
John Ralls
e17ba3cc00 Fix UAF in xaccFreeSplit.
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.
2023-11-02 12:58:55 -07:00
John Ralls
2234fa433e Add Asan build type that enables the Address and UB sanitizers.
Uses generator statements instead of CMAKE_<TYPE>_FLAGS_ASAN to support multiconfig generators like Xcode.
2023-11-02 12:58:46 -07:00
John Ralls
a389e0a32e Bug 799092 - GnuCash 5.4 leaves background process running on exit
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.
2023-10-02 12:31:59 -07:00
Christopher Lam
550c43d13a Merge branch 'free-guid-string' into stable #1777 2023-09-20 07:29:16 +08:00
John Ralls
a49fd0bc09 [c++options] Correctly implement handling Fancy Date Format.
It's not a simple string.
2023-09-19 16:05:53 -07:00
Christopher Lam
8e21d3328f guid_to_string should be freed. 2023-09-19 20:31:11 +08:00
John Ralls
17ebb8a1d2 [simple-business-create.py] Overwrite an existing file instead of crashing. 2023-09-11 17:39:02 -07:00
Christopher Lam
7ce4198c20 rename string_to_gnc_numeric to gnc_numeric_from_string 2023-08-29 08:45:20 +08:00
Christopher Lam
75f6ee1817 [test-scm-engine] tests gnc-numeric-from-string 2023-08-29 08:30:52 +08:00
Geert Janssens
29b7a9099d Fix cmake warnings while searching for python
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.
2023-08-17 18:23:33 +02:00
Christopher Lam
867867da53 Merge Richard Cohen branch 'fix-leaks-in-tests' into stable #1713 2023-07-24 13:09:55 +08:00
John Ralls
50418527b0 Fix two typos. 2023-07-21 13:57:39 -07:00
John Ralls
2e76d2f43d Bug 799021 - Saved report renders default of gnc-register-list-option
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.
2023-07-20 14:25:25 -07:00
Richard Cohen
e43982375c Valgrind: fix "definitely lost" memory in test - sqlite3test
==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)
2023-07-19 10:21:30 +01:00
Christopher Lam
2a392633ed Bug 798991 - Incorrect Account Name Order in Transaction Report
gnc:string-locale<? uses glib instead of guile string compare
2023-07-11 08:41:09 +08:00
Richard Cohen
3c0b051ab0 Valgrind: fix "Mismatched free/delete" for gnc_print_time64, qof_print_date
... 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)
...
2023-06-20 10:20:44 +01:00
Richard Cohen
3957272ef0 Fix some typos in comments 2023-05-13 13:00:25 +01:00
Christopher Lam
56b75c3691 std::string cannot free() scm_to_utf8_string automatically 2023-04-04 23:24:22 +08:00
John Ralls
30cbf3074e Fix misplaced static variable decl.
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.
2023-04-02 15:24:56 -07:00
John Ralls
d8a3e83189 Fix test breakage from account list reversal. 2023-04-01 18:14:31 -07:00
John Ralls
634b9f8744 Bug 798810 - Income Statement (multicolumn) - account sorting is...
'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.
2023-03-31 16:43:42 -07:00
Richard Cohen
9fa2a48fe1 Fix build on gcc-8 & 9.
See https://lists.gnucash.org/pipermail/gnucash-devel/2023-March/046617.html
2023-03-30 18:25:23 -07:00
John Ralls
b4b8431984 Bug 798778 - GnuCashquits abruptly when attempting to edit options…
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.
2023-03-16 17:50:06 -07:00
John Ralls
a44b3664e2 [c++options] Implement GncOptionGncOwnerValue class.
GncOwners aren't QofInstances and have limited lifetimes so an option
must hold its own, wrapped in std::unique_ptr for memory management.
2023-03-14 16:11:39 -07:00
Richard Cohen
329a2f7d42 Guard against some possible null pointer dereferences
Found by gcc 12 when compiling with "-O2 -Wnull-dereference"
2023-03-08 11:00:56 +00:00
John Ralls
1341511edb [c++options] Save an empty SCM string for nil or empty option values.
Avoids crash at reload due to unknown variable.
2023-03-06 15:36:23 -08:00
John Ralls
1eecb9f5c0 [c++ options] Fix locale dependency in test-gnc-option-scheme-output.
Created by using std::to_string() in GncOptionRangeValue::serialize.
It wraps sprintf that reads the locale. Use ostringstream instead.
2023-03-02 12:22:55 -08:00
Richard Cohen
be41bde58a Add missing MAKE_LINKS, and the local scm directory to %load-path
Before this change, "make check" would fail after
  rm -rf ${build}/share/guile/site/*/gnucash/
2023-02-28 11:51:23 +00:00
Richard Cohen
ec169e6e24 Fix some non-translatable typos 2023-02-27 11:32:12 +00:00
John Ralls
408b5ec216 [c++ options] Restore forward & backward compatibility, fix crash.
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.
2023-02-25 16:25:36 -08:00
Richard Cohen
bddb4468fa Import GLIB2 as a target, and use it to simplify the CMakeLists 2023-02-21 12:59:42 +00:00