Commit Graph

2262 Commits

Author SHA1 Message Date
Christopher Lam
1b50c6261a g_list_free xaccAccountGetSplitList 2024-04-16 00:09:52 +08:00
Christopher Lam
606da28d25 use xaccAccountGetSplitsSize 2024-04-16 00:09:52 +08:00
Christopher Lam
f70ee754fc use xaccAccountGetSplits and gnc_account_find_split 2024-04-16 00:09:52 +08:00
Christopher Lam
3f7a5a8267 [Account.hpp][API] xaccAccountGetSplits and gnc_account_find_split 2024-04-16 00:09:52 +08:00
Christopher Lam
a54caaab61 [Account.cpp] GetBalanceAsOfDate gets std::function instead of bool 2024-04-15 23:21:16 +08:00
Christopher Lam
cc10b9a0b7 [SX-book.c] tidy for loop
because splits will need to be g_list_free in a future commit
2024-04-15 22:22:48 +08:00
Christopher Lam
c1ee59c39b [Account.h] size_t xaccAccountGetSplitsSize returns g_list_length (splits)
which is easily replaced with vector.size()
2024-04-14 23:29:20 +08:00
Christopher Lam
f08e0f5b61 [policy.cpp] rewrite to avoid goto 2024-04-14 23:29:20 +08:00
Christopher Lam
2251bf8966 [Account.hpp] use std::optional for cached values
whereby {} denotes uncached values
2024-04-13 20:56:55 +08:00
Sherlock
f0d45de642
Resolve test assert. 2024-04-12 15:52:39 -07:00
Sherlock
8d6f748aca
Bug 799281 - Deleting a transaction may trigger a crash
Update qof_collection_lookup_entity() to prevent returning instances marked to be destroyed.
2024-04-12 15:34:14 -07:00
Christopher Lam
df0fc05223 Merge branch 'more-engine-cpp' into stable #1889 2024-04-12 23:13:50 +08:00
Christopher Lam
8c94132f13 Bug 799268 - Cannot write a check over $1000
this is caused by d52d226e5b which caused log_val, pow_val, this_part
to be kept as float instead of the original algorithm which required
casting to int.
2024-04-10 13:30:59 +08:00
Christopher Lam
d100df7ef7 [AccountP.hpp] .h -> .hpp, remove extern "C" {} wrapper 2024-04-02 21:09:40 +08:00
Christopher Lam
a67e4651c3 [Query.cpp] convert to cpp 2024-04-02 21:09:40 +08:00
Christopher Lam
4d9836aac2 [TransLog.cpp] convert to cpp 2024-04-02 21:09:40 +08:00
Christopher Lam
093781c018 [policy.cpp] convert to cpp 2024-04-02 21:09:40 +08:00
Christopher Lam
f913bed7e6 [gnc-engine.cpp] convert to cpp 2024-04-02 21:09:40 +08:00
Christopher Lam
96f041a1d6 [cap-gains.cpp] convert to cpp 2024-04-02 21:09:39 +08:00
Christopher Lam
79b7267cdd [cashobjects.cpp] convert to cpp 2024-04-02 21:09:39 +08:00
Christopher Lam
67d024c11f [Scrub3.cpp] convert to cpp 2024-04-02 21:09:39 +08:00
Christopher Lam
6b5a4d7c11 [Scrub2.cpp] convert to cpp 2024-04-02 21:09:39 +08:00
Christopher Lam
ddfa664601 [Scrub.cpp] convert to cpp 2024-04-02 21:09:39 +08:00
Christopher Lam
dab32807ef [engine/*.cpp] NULL -> nullptr changes
It's the done thing
2024-04-02 21:09:39 +08:00
Christopher Lam
9a85eb4a2a [engine/*.h] add extern "C" {} wrappers 2024-04-02 21:09:39 +08:00
Christopher Lam
4945db6b7d [AccountP.h] remove struct members obsolete with 76014f18a0
forgot to remove
2024-03-29 22:08:40 +08:00
Christopher Lam
6c82a1311b [sixtp-dom-parsers.cpp] use string_to_guint, string_to_guint16 2024-03-26 20:55:25 +08:00
Christopher Lam
249ec9f43a [test-string-converters.cpp] add some string->number tests 2024-03-26 20:55:25 +08:00
Christopher Lam
1f9ea6bc99 [sixtp-utils.cpp] std::from_chars speedup, remove string_to_gint32
Benchmarks running tests 4E6 times:

using sscanf

$ bin/test-string-converters
 elapsed=7.33942s
Executed 92000006 tests. All tests passed.
$ bin/test-string-converters
 elapsed=7.3811s
Executed 92000006 tests. All tests passed.
$ bin/test-string-converters
 elapsed=7.3455s
Executed 92000006 tests. All tests passed.

with std::from_chars

$ bin/test-string-converters
 elapsed=4.47369s
Executed 92000006 tests. All tests passed.
$ bin/test-string-converters
 elapsed=4.46908s
Executed 92000006 tests. All tests passed.
$ bin/test-string-converters
 elapsed=4.47067s
Executed 92000006 tests. All tests passed.
$ bin/test-string-converters
 elapsed=4.48706s
Executed 92000006 tests. All tests passed.
2024-03-26 20:55:00 +08:00
Christopher Lam
ba403e4a7c [guid.hpp] GUID::from_string and is_valid_string takes a const char*
boost::uuids::string_generator has operator()(const char*).

thus we can avoid allocating std::string, with a consistent 4% speedup
2024-03-17 09:07:59 +08:00
Christopher Lam
cba7da30fd [gnc-date.cpp] specialise iso-8601 parsing where TZ=+0000
- avoid allocating new TZPtr
- parse y/m/d/h/m/s and construct PTime directly
- avoid boost's time_from_string which creates an std::string
2024-03-14 08:48:31 +08:00
Christopher Lam
27c16517e9 [gnc-numeric.cpp] shortcut parsing num/denom as gnc_numeric
The gnc_numeric is serialised as "num/denom" with no whitespace, and
denom > 0. This function takes advantage of std::from_chars to parse
it. The "num" serialisation is also optimised as a free side effect of
this function.
2024-03-11 19:16:06 +08:00
Christopher Lam
11da03bc67 [gtest-gnc-numeric.cpp] test int64 limits for GncNumeric 2024-03-11 19:15:48 +08:00
John Ralls
af18ea598e Bug 799093 - Cannot reconcile since v5.4
Covers the final case where having the reconcile window open and
auto-completing a transaction then deleting the transaction before
committing it leaves the transaction in the reconcile window.

We need to signal that the account is modified even if it isn't
because that's what the reconcile window is watching.
2024-03-11 10:20:02 +01:00
John Ralls
2db6988e25 Remove bogus include. 2024-03-01 15:31:35 -08:00
John Ralls
8ebac5b596 Bug 799213 - SIGSEGV caused by revising an auto completed transaction
Calling xaccSplitDestroy without also calling xaccSplitCommitEdit then
deleting the split list before calling xaccTransCommitEdit prevents
xaccSplitCommitEdit from being called on the supposedly deleted
splits. Not only does this leak them it leaves them in the book
potentially with a dangling parent pointer.
2024-02-29 14:29:40 -08:00
Christopher Lam
229d9300cf [engine-helpers.h] key is a const char*
thus allowing compilation in cpp with stricter type checking
2024-02-25 22:39:38 +08:00
Christopher Lam
c345fc9d3c add #ifdef __cplusplus extern "C" {} wrappers to .h files 2024-02-25 22:39:38 +08:00
Christopher Lam
6cb2eeeaa8 Merge branch 'more-engine-cpp' into stable #1866 2024-02-22 07:39:35 +08:00
John Ralls
226bfea108 Fix a bunch of UB errors from ASAN about mismatched function types.
The casts fool the compiler but not the UB sanitizer.
2024-02-20 15:33:11 -08:00
John Ralls
7bd97f15d0 Fix transaction delete use-after-free, take 2.
The problem with take 1 was that the duplicate split uses the same lot
and account pointers without adding itself to those lists, causing
checks in unit tests to fail.
2024-02-20 15:10:05 -08:00
John Ralls
8546aa975e Revert "Fix two use-after-free issues found by address sanitizer."
This reverts commit 4dbf803041.

The use-after free errors are caused by the compiler reordering the
steps in xaccSplitFree and Transaction's do_destroy. Unfortunately the
corrections here caused trouble in other places, leading to test failures.
2024-02-19 21:11:54 -08:00
John Ralls
4dbf803041 Fix two use-after-free issues found by address sanitizer. 2024-02-19 14:33:43 -08:00
Christopher Lam
28cc26f207 [gnc-commodities.cpp] gnc_new_iso_codes is a std::unordered_map 2024-02-19 11:21:24 +08:00
Geert Janssens
00640f9ded Replace naked for loops with C++ algorithms 2024-02-18 23:18:16 +08:00
Geert Janssens
0732436e44 A few NULL/nullptr related cleanups 2024-02-18 23:18:16 +08:00
Christopher Lam
17f422f97c [gnc-commodity.cpp] convert quote_sources to vector
- all quote sources are now vector
- get_quote_source_from_type to convert QuoteSourceType to vector<gnc_quote_source>
- the quote sources are modifiable, therefore cannot be const:
see gnc_quote_source_set_fq_installed
2024-02-18 23:17:55 +08:00
John Ralls
266ae2a931 Bug 798946 - start/end of current/last quarter have off-by-one error
Calculating the quarter offset when the current month is less than the
beginning month of the fiscal year was inverted.
2024-02-17 12:52:17 -08:00
Christopher Lam
164453a858 [gnc-commodity.cpp] gnc_quote_source_get_index searches index
we can now remove init
2024-02-17 22:55:41 +08:00
Christopher Lam
5d16d025a6 [gnc-commodity.cpp] gnc_quote_source_s is a cpp class
... this ensures the new_quote_sources vector now doesn't leak anymore.
2024-02-17 22:55:41 +08:00