Commit Graph

2262 Commits

Author SHA1 Message Date
Christopher Lam
770045c4a5 [gnc-quotes.cpp] remove sources_as_glist() 2024-02-17 22:55:41 +08:00
Christopher Lam
346499ae04 [gnc-commodity.cpp] gnc_quote_source_set_fq_installed takes a StrVec
instead of a GList* of strdup'd chars
2024-02-17 22:55:40 +08:00
Christopher Lam
47a1a56f16 [gnc-commodity.cpp] fq_version is a std::string
thus can free itself on exit
2024-02-17 22:55:40 +08:00
Christopher Lam
f49c2735e3 [gnc-commodity.cpp] initialize quote_sources at compile-time 2024-02-17 22:55:40 +08:00
Christopher Lam
d488faacb2 [gnc-commodity.cpp] Convert to cpp 2024-02-17 22:55:40 +08:00
Vincent Lucarelli
f5b7bf3401 removed old_internal_name from gnc_quote_source_s (deprecated) 2024-02-17 22:52:40 +08:00
Christopher Lam
9035391907 [test-commodities.cpp] add some tests for gnc_quote_sources 2024-02-17 22:43:52 +08:00
Christopher Lam
03c5309666 [gnc-lot.cpp] convert to cpp 2024-02-09 17:23:51 +08:00
Christopher Lam
7d8d8f83be [Recurrence.cpp] convert to cpp 2024-02-09 17:23:51 +08:00
Christopher Lam
783c3df3c0 [Transaction.cpp] convert to cpp 2024-02-09 17:23:51 +08:00
Christopher Lam
fc5d7f872e [Split.cpp] convert to cpp 2024-02-09 17:23:51 +08:00
Christopher Lam
698cc23051 Add #ifdef __cplusplus extern "C" {} wrappers to .h files 2024-02-08 21:26:47 +08:00
Christopher Lam
928f9245e6 [gtest-gnc-numeric] add operator comparisons
with example int64 numbers
2024-01-29 08:55:56 +08:00
Christopher Lam
a301544376 Merge branch 'stock-acct-metadata' into stable #1858 2024-01-27 14:26:13 +08:00
Christopher Lam
688032b590 [app-utils/gnc-ui-balances.cpp] convert to cpp 2024-01-27 03:45:11 +08:00
Christopher Lam
9782918586 [account.cpp] add more account metadata - assoc account
the tag denotes the type of associated account eg. "dividend"
"capgains" "cash" "fees"
2024-01-26 20:54:20 +08:00
Alex Aycinena
54da44b3ca Update Form/Schedule line references for 2023 for the US Income Tax Report 2024-01-16 11:44:10 -08:00
John Ralls
c87d480b0d Move gnc_list_formatter from gnc-date to gnc-ui-util.
It has nothing at all to do with dates.
2024-01-06 18:16:31 -08:00
John Ralls
d52d226e5b Convert gnc-ui-util to C++. 2024-01-06 18:08:39 -08:00
John Ralls
b2fa3ef106 Bug 799210 - Bad encoding of accented chars in account names in...
"Import CSV" wizard

In MSWin the UnicodeString(char*) ctor assumes that the input string
is encoded in the current codepage, but the input to
gnc_list_formatter is encoded in UTF8. Use the static class function
UnicodeString::fromUTF8 instead.
2024-01-06 10:30:14 -08:00
John Ralls
e22a57ad26 Merge John Ralls's 'asan' into stable. 2023-12-08 14:56:29 -08:00
John Ralls
6834cb5025 Implement coverage option
To use pass -DCMAKE_BUILD_TYPE=Debug or Asan -DCOVERAGE=ON and build as
usual, then do ninja lcov-initialize && ninja check && ninja
lcov-collect. The result will be a directory, <Builddir>/Coverage
containing lcov tracefiles, including an aggregate file gnucash.info
which you can use for further processing. It will also report an overall summary.
Note that only C/C++ files are included.

There's one more target, lcov-generate-html, that you can run after
lcov-collect. It will generate a simple website in
<Builddir>/Coverage-HTML showing coverage by source directory (the
directories in <Builddir> have coverage for generated files). Each
directory path is a clickable link to a page that shows coverage for
each source file; the filenames link to a page for each showing which
lines have been exercised.
2023-12-08 14:53:02 -08:00
John Ralls
6bc12898a8 GncDate: Remove now-superfluous base parameter. 2023-12-08 13:49:28 -08:00
John Ralls
1e289cb2b8 GncDate: Remove pointless normalize_month function.
Suggested by Sherlock.
2023-12-08 13:47:24 -08:00
John Ralls
966cef19aa Bug 799156 - normalize_struct_tm() does not normalize seconds,...
minutes, and hours correctly.

Fix proposed by Sherlock.
2023-12-08 13:45:04 -08:00
John Ralls
5005c3cac8 Merge Sherlock's 'bug799151' into stable. 2023-12-07 17:31:33 -08:00
Sherlock
ae8492d73a Update test-gnc-date.c 2023-12-07 17:31:19 -08:00
Sherlock
5a7b6e9814 Bug 799151 - gnc_date_get_last_mday () does not account for,,,
leap years correctly.
2023-12-07 17:30:08 -08:00
Sherlock
07e94b4222 Bug 799152 - normalize_reldate_tm() does not handle dates with...
months greater than 11 or less than -11 correctly.
2023-12-07 16:53:05 -08:00
John Ralls
d8dacb86b2 Bug 799143 - FTBFS on 32bit architectures
Fix misuse of GUINT_TO_POINTER in 5e09b66.
2023-11-28 01:47:12 +00:00
John Ralls
92de074e49 Bug 799144 - Date Completion is broken after 5.4 upgrade
strptime will reasonable return false for an incomplete date but it
still fills in the parts of the struct tm that it understands, so bail
out of qof_scan_date_internal when it fails only if all three fields
are present.
2023-11-26 09:23:58 -08:00
John Ralls
ed4921271c Bug 799134 - Fails to build with GCC 14 (‘find_if’ is not a member...
of ‘std’; did you mean ‘find’)
2023-11-21 15:27:04 -08:00
Christopher Lam
1d26d99ddb [gnc-budget] use std::optional<gnc_numeric> instead of bool+gnc_numeric
more expressive
2023-11-18 08:59:32 +08:00
John Ralls
dd0b72cdb5 Fix global array index out of range.
Tests must set the account type to avoid errors in xaccAccountOrder.
2023-11-17 15:20:29 -08:00
Christopher Lam
fdcb8b46bd [sixtp-dom-generators.cpp] char* must be freed 2023-11-11 12:45:57 +08:00
Christopher Lam
8f7eecd3e9 Merge branch 'icu-list-formatter' into stable #1791 2023-11-10 18:58:35 +08:00
Christopher Lam
9e47c297ba Merge branch 'plug-recurrence-to-string' into stable #1812 2023-11-07 06:28:39 +08:00
Christopher Lam
6940488d2d recurrencePeriodTypeToString and recurrenceWeekendAdjustToString g_strdup only when necessary
... for sql use only. xml use assumes they return a const char*.
2023-11-06 14:12:17 -08:00
Christopher Lam
12f4233396 recurrencePeriodTypeToString and recurrenceWeekendAdjustToString g_strdup only when necessary
... for sql use only. xml use assumes they return a const char*.
2023-11-06 17:37:17 +08:00
Adam Wight
fbc183a544 Always return an allocated gchar*
Returning the literal string will cause the caller to free unallocated
memory.
2023-11-05 23:58:01 +01:00
John Ralls
f67b53a440 Xml backend tests: Use libgnc-backend-xml-utils instead of sources.
Every test was rebuilding it except for gnc-backend-xml.cpp from
scratch, no point in that plus the Address Sanitizer needs the
definition of GncBackendXml.
2023-11-02 12:58:55 -07:00
John Ralls
fa119f8d17 Split test other 2023-11-02 12:58:55 -07: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
Christopher Lam
d617129db8 avoid strlen where possible
if testing emptiness, test *str instead.
2023-11-01 22:43:16 +08:00
Simon Arlott
90c9aaf4cb
Bug 799108 - "Since Last Run" crashes if there are any errors creating a scheduled transaction
Pass a creation_errors list to gnc_sx_instance_model_effect_change() so
that errors creating SX can be stored, and then display them.
2023-10-21 20:39:23 +01:00
John Ralls
4592530318 Bug 799099 - Crash when trying to get quotes
The comment on gnc_pricedb_add_price says that writing to the
GNCPrice* after calling it will produce interesting results, and
calling gnc_price_commit_edit and g_object_unref both qualify, so
remove those calls and the corresponding gnc_price_begin_edit.
2023-10-20 08:46:57 -07:00
Sherlock
52f1076b30
Bug 799104 - "Asset Chart" broken 2023-10-13 16:58:54 -07:00
John Ralls
44c278a82c Fix GncDateEntry date parsing oddities.
The intent was always to default to today if the input string isn't
parsable, but two problems prevented that: First,
qof_scan_date_internal didn't check the return value of strptime and
return FALSE if it failed and second gnc_date_edit_get_date_internal
would unnecessarily munge a valid struct tm from gnc_tm_get_today_neutral.
2023-10-12 15:51:35 -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
ab7ead39ca use icu::ListFormatter to combine a list strings into a string 2023-10-02 17:52:54 +08:00
Christopher Lam
d1b2368f4d Merge Yongun Seong's branch 'utest-gnc-pricedb-types' into stable #1784 2023-09-27 22:16:39 +08:00
Yongun Seong
0bd556c581
[utest-gnc-pricedb] fix test failure due to callback type mismatch 2023-09-25 15:38:06 +09:00
John Ralls
422fd0cab2 Fix misspelled/missing dist files. 2023-09-23 14:01:11 -07:00
John Ralls
776a430734 Bug 798904 - GnuCash on Windows opens a CMD window at startup.
Applied patch from bug report supplied by "Sherlock".
2023-09-22 13:21:11 -07:00
John Ralls
90b9142096 [DBI backend] Change DBI test URLs to environment variables.
From cmake configuration definitions.
2023-09-21 14:33:50 -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
d21698f7cf [gnc-option-impl] don't leak char*
use the stack
2023-09-19 07:59:53 +08:00
Christopher Lam
55b9382ad9 [utest-gnc-backend-sql] properly clean up QofBook 2023-09-19 07:59:38 +08:00
Christopher Lam
01f27e9c53 [test-commodities] clean up commodities 2023-09-19 07:59:38 +08:00
Christopher Lam
fccf0b48c4 [utest-Account] g_free char* 2023-09-19 07:59:38 +08:00
Christopher Lam
c074b82224 [test-qofsession] plugs Account* leak 2023-09-17 08:37:09 +08:00
Christopher Lam
1ddee7dc3f [test-qofbook] plugs Account* leak 2023-09-17 08:37:04 +08:00
Christopher Lam
a81bc72fb1 [test-sx] plug some leaks 2023-09-16 08:42:42 +08:00
Christopher Lam
94211c2e57 [test-sx] plug some leaks 2023-09-16 08:42:40 +08:00
Christopher Lam
14622e7db6 [test-print-parse-amount] plug leaks 2023-09-16 05:46:46 +08:00
Christopher Lam
c44194606a [test-xml-pricedb] free a sixtp parser 2023-09-15 23:55:06 +08:00
Christopher Lam
34564ef6d0 [test-qofobject] plug some leaks 2023-09-15 23:34:43 +08:00
Christopher Lam
8277f4d559 [test-qofbook] plug leaks 2023-09-15 23:34:43 +08:00
Christopher Lam
0056e5f091 [gtest-import-map] plug leaks 2023-09-15 23:34:43 +08:00
Christopher Lam
235e24a055 [account.cpp] ~GncImapInfo = gnc_account_imap_info_destroy 2023-09-15 23:34:43 +08:00
Christopher Lam
db77fb81a5 [test-job] plug leaks 2023-09-15 23:34:43 +08:00
Christopher Lam
a8dffb8559 [gnc-date.cpp] don't alloc tm* unless GncDateTime() succeeds
because GncDateTime() may throw an exception, in which case time will
leak. mainly leaks in test suite.
2023-09-15 23:33:47 +08:00
Christopher Lam
5a03d9798c [gnc-sx-instance-model] g_free char* 2023-09-15 23:33:47 +08:00
John Ralls
16c9957cac Bug 798925 - Python bindings: "invalid unclassed pointer...
in cast to 'QofInstance'".

The list ended up with two entries of payment_lot resulting in a
dangling reference when one of them was freed.
2023-09-11 17:40:48 -07:00
John Ralls
89360252fb Bug 798983 - Empty Orphan account appears after entering transactions in 5.3
Caused by trying to set the account on the blank split. The blank split
was present because the method used to clear the split list for the
receiving transaction in gnc_float_txn_to_txn_swap_accounts only removed
splits that belong to the transaction, and the blank split doesn't.

Adds new function xaccTransClearSplits to do a more thorough job.
Also improve the documentation for xaccSplitDestroy to better explain when
a transaction will be destroyed if it empties the split list.

 # Please enter the commit message for your
changes. Lines starting
2023-09-08 15:08:44 -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
c45b9736ab [gnc-numeric.cpp] parse integer + fraction; e.g."10 1/4" == 10.25 2023-08-29 08:30:30 +08:00
Geert Janssens
e2f8233e1e Bug 798950 - Bug Report: Incorrect Currency Conversion and Provider Invoice Payment Recording
- Balancing lots always involves splits in the same account. So
  the relevant number to use in the calculations is the split
  amount, not the split value.
- Additionally don't assume transactions are single-currency.
  So if amounts change, recalculate the associated values
  based on deduced exchange rates.
- Finally if the lot balancing resulted in a split to be broken up
  into two splits use conservative calculations for the new
  splits' values to avoid introducing imbalances due to
  rounding errors.
2023-08-21 16:01:27 +02:00
Mike Alexander
3aa6e60f95 fix debugging output, no functional change. 2023-08-16 00:07:56 -04:00
Christopher Lam
f8546dc4da Fix compilation error from 5781f3445b 2023-08-11 23:35:10 +08:00
John Ralls
73dec63d1d Eliminate a frequent exception in guid_from_string
By not trying to construct a GUID from an empty string.
2023-08-10 14:05:10 -07:00
John Ralls
5781f3445b SQLBackend: Use std::optional return value instead of exceptions
For wrong value type when retrieving a value from the SQL results row.

Profiling showed that most of the SQL load time was spent in handling
these exceptions, and using std::optional instead produced a > 11x
speedup (10 seconds vs. 115 seconds) when loading a large file.
2023-08-10 14:05:10 -07:00
John Ralls
a5404f6607 Improve reporting when parse_quote throws an exception.
Add more detail to the error message and pass the right value to the
gnc_error_dialog so that the error is actually displayed to the user.
2023-08-08 15:41:16 -07:00
Christopher Lam
e91752dba2 [gnc-ui-util.c] plug GList* leak
because gnc_account_get_children should have been freed.
2023-08-08 19:59:54 +08:00
Christopher Lam
fc21c55a0b [gnc-pricedb.cpp] more glib g_list uses
* use g_list_find_custom where appropriate
* also g_list_free_full and g_list_foreach
2023-08-07 08:39:07 +08:00
Christopher Lam
d89544563d Revert "[gnc-pricedb.cpp] use std::pair instead of a struct for PriceTuple"
This reverts commit 2d730e38d5.
2023-08-05 11:02:57 +08:00
Christopher Lam
2d730e38d5 [gnc-pricedb.cpp] use std::pair instead of a struct for PriceTuple 2023-08-04 20:34:07 +08:00
Christopher Lam
6b741ddf32 [gnc-pricedb.cpp] use forloop instead of do..while and while
because they're scanning GLists, and forloop is tidier than while
2023-08-04 20:33:02 +08:00
John Ralls
4d46a8191d Merge Simon Arlott's 'test-xml-save' into stable. 2023-08-03 11:05:11 -07:00
Christopher Lam
79c0fe4724 [gnc-pricedb.cpp] convert hash_table_to_list to hash_table_to_vector 2023-08-03 00:34:30 +08:00
Christopher Lam
5e09b662a1 [utest-gnc-pricedb] test gnc_pricedb_foreach_price both stable and unstable 2023-08-03 00:33:52 +08:00
Christopher Lam
040ccb79b6 [gnc-pricedb.cpp] rewrite price_list_insert more efficiently
no need for PriceListIsDuplStruct
and shortcut "return true" if price is a duplicate
2023-08-02 23:23:00 +08:00
Christopher Lam
d6b49bbc89 [utest-gnc-pricedb.c] tests gnc_pricedb_price_list_insert
especially skipping adding duplicate price
2023-08-02 23:19:20 +08:00
Simon Arlott
35bee1382d
Test loading and saving XML files with and without compression
Add new test files that are written with the latest version of GnuCash.
Test loading them, saving to compressed files, loading those compressed
files and writing to an uncompressed file. At every stage check it matches
the canonical version.
2023-07-30 19:11:57 +01:00
John Ralls
dee01706eb Merge John Ralls's 'bug798958' into stable. 2023-07-28 12:10:22 -07:00
John Ralls
cbe765c6d9 Bug 798958 - gncScrubLotLinks will infinite loop in some conditions
The conditions being containing a split from a voided transaction.
Instead of trying to destroy zero-value splits (doomed to fail in
that instance and generally rude otherwise) just remove them from
the lot list.
2023-07-27 14:46:55 -07:00
Christopher Lam
867867da53 Merge Richard Cohen branch 'fix-leaks-in-tests' into stable #1713 2023-07-24 13:09:55 +08:00