Commit Graph

182 Commits

Author SHA1 Message Date
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
Geert Janssens
1def3ce8fd Cleanup - remove deprecated function (re-)defines
They were deprected 11 years ago
2024-06-23 18:23:49 +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
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
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
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
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
Christopher Lam
75f6ee1817 [test-scm-engine] tests gnc-numeric-from-string 2023-08-29 08:30:52 +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
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
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
Christopher Lam
4d977a947a [business-core] remove gnc:split->owner 2023-02-13 23:29:00 +08:00
Christopher Lam
d53f3e68d1 Merge branch 'maint' 2023-02-13 23:28:44 +08:00
Christopher Lam
4953cf94fa [reports] use gnc:make-split->owner with guardian
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.
2023-02-13 23:17:02 +08:00
Richard Cohen
78ec20515b Remove some unused variables - and the initialization
- checked that any side effects were irrelevant
2023-02-06 14:20:28 +00:00
Richard Cohen
ea2d3be217 Remove some unused variables with obviously no side effects 2023-02-06 14:19:22 +00:00
Richard Cohen
1cec0cb3f3 Use internal extern "C" { ... } for C++
- removes warnings compiling swig engine
...
[ 10%] Generating swig-engine.cpp
.../libgnucash/engine/engine-helpers.h:31: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gnc-date.h:83: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/qofquery.h:90: Warning 302: Identifier 'QofQuery' redefined (ignored),
.../libgnucash/engine/gnc-option.hpp:55: Warning 302: previous definition of 'QofQuery'.
.../libgnucash/engine/gnc-commodity.h:56: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncBusiness.h:40: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncEntry.h:37: Warning 313: Unrecognized extern type "C++".
2023-01-23 18:40:01 +00:00
Frank H. Ellenberger
d039e65aca Merge branch 'maint' 2023-01-22 11:25:44 +01:00
John Ralls
09751e20c5 Bug 789730 Bis: Sometimes we get lists of Account*
And sometimes a list of Guid strings. Handle either.
2023-01-21 15:57:39 -08:00
John Ralls
816219c246 Bug 798730 - Open report doesn't remember selected accounts over restart
scm_to_value<GncOptionAccountList> written for std::vector<Account*>
instead of std::vector<GncGUID>.
2023-01-20 13:22:26 -08:00
Christopher Lam
645cc9461d [core-utils] modify gnc:format to accept -
this allows use of varnames such as ${report-title}
2023-01-17 00:24:08 +08:00
John Ralls
61673ec919 [c++ options] Rearrange header includes to avoid windows.h conflicts.
Since SWIG guile pulls in libguile early the options headers must
be included in a begin block.
2023-01-08 16:09:32 -08:00
John Ralls
d4a1fb92a6 [c++ options] strptime.h must be included as extern "C". 2023-01-08 16:08:04 -08:00
John Ralls
40c55899bc [c++options] Convert remaining reports and tests to new API. 2022-12-23 10:01:52 -08:00
John Ralls
30b2c0bcac [options] Provide gnc:register-multichoice-callback-option.
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.
2022-12-22 13:53:44 -08:00
John Ralls
b8c0673526 Merge branch 'maint' 2022-12-19 12:11:32 -08:00
Christopher Lam
6e6d44f567 [options.scm] typo fix - no commas needed in guile
also the following symbols are also not accessible from scheme.

GncOptionUIType-TAX_TABLE
GncOptionUIType-DATE_FORMAT
2022-12-17 21:23:54 +08:00
John Ralls
b4bab92da2 Bug 798664 - Result of 'gnucash --nofile' is marked dirty
Don't create a new book in the new-user dialog unless the user says to.
Don't automatically create a new book when retrieving default commodities
because the retrieve might be requested in a context like the Preferences
dialog when there is no book.

Some report tests relied on requesting the default commodity creating
the book, so in those tests ensure that the book is created first.
2022-12-12 11:30:59 -08:00
John Ralls
939a77407c Merge branch 'price-quotes-cpp' 2022-10-14 11:25:14 -07:00
Mike Alexander
3c306eae65 Merge branch 'maint' 2022-10-09 22:27:55 -04:00