Commit Graph

2153 Commits

Author SHA1 Message Date
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
Christopher Lam
920f760dd8 Merge Richard Cohen branch 'fix-some-leaks-on-error-path' into stable #1714 2023-07-24 13:08:38 +08:00
Christopher Lam
cdc5b6a796 Merge Richard Cohen branch 'fix-test-leaks-from-get-random-string' into stable #1715 2023-07-24 13:07:40 +08:00
Christopher Lam
e841ceaaa1 [gnc-pricedb.cpp] convert to cpp 2023-07-23 15:19:43 +08:00
John Ralls
c5181180ad Fix GncOptionMultichoiceValue list tests
To conform to changes in 84eb084375.
2023-07-20 21:24:31 -07:00
Richard Cohen
a36844720d Valgrind: fix "definitely lost" memory from get_random_string() - test-vendor
==88804== 8 bytes in 1 blocks are definitely lost in loss record 12 of 479
==88804==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88804==    by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88804==    by 0x10B5D8: get_random_string_without (test-stuff.c:312)
==88804==    by 0x10B655: get_random_string (test-stuff.c:333)
==88804==    by 0x10AA92: test_string_fcn (test-vendor.c:138)
==88804==    by 0x10A76B: test_vendor (test-vendor.c:88)
==88804==    by 0x10AD5A: main (test-vendor.c:246)

+ 3 more
2023-07-20 15:23:09 +01:00
Richard Cohen
30b47d1669 Valgrind: fix "definitely lost" memory from get_random_string() - test-job
==88779== 8 bytes in 1 blocks are definitely lost in loss record 9 of 461
==88779==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88779==    by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88779==    by 0x10B871: get_random_string_without (test-stuff.c:312)
==88779==    by 0x10B8EE: get_random_string (test-stuff.c:333)
==88779==    by 0x10AB9F: test_string_fcn (test-job.c:157)
==88779==    by 0x10A7B1: test_job (test-job.c:87)
==88779==    by 0x10AFF3: main (test-job.c:262)

+ 3 more
2023-07-20 15:23:09 +01:00
Richard Cohen
49240e9b5a Valgrind: fix "definitely lost" memory from get_random_string() - test-employee
==88366== 8 bytes in 1 blocks are definitely lost in loss record 11 of 474
==88366==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88366==    by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88366==    by 0x10B7E9: get_random_string_without (test-stuff.c:312)
==88366==    by 0x10B866: get_random_string (test-stuff.c:333)
==88366==    by 0x10AB64: test_string_fcn (test-employee.c:140)
==88366==    by 0x10A7C1: test_employee (test-employee.c:87)
==88366==    by 0x10AF6B: main (test-employee.c:246)

+ 4 more
2023-07-20 15:23:05 +01:00
Richard Cohen
2f0c045187 Valgrind: fix "definitely lost" memory from get_random_string() - test-customer
==88327== 8 bytes in 1 blocks are definitely lost in loss record 13 of 667
==88327==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88327==    by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88327==    by 0x10B890: get_random_string_without (test-stuff.c:312)
==88327==    by 0x10B90D: get_random_string (test-stuff.c:333)
==88327==    by 0x10AC7A: test_string_fcn (test-customer.c:146)
==88327==    by 0x10A82E: test_customer (test-customer.c:79)
==88327==    by 0x10B012: main (test-customer.c:229)

+ 3 more
2023-07-20 15:23:01 +01:00
Richard Cohen
394823a734 Valgrind: fix "definitely lost" memory from get_random_string() - test-commodities
==88718== 8 bytes in 1 blocks are definitely lost in loss record 21 of 1,880
==88718==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88718==    by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88718==    by 0x11D6B9: get_random_string_without (test-stuff.c:312)
==88718==    by 0x11D736: get_random_string (test-stuff.c:333)
==88718==    by 0x116A91: test_commodity() (test-commodities.cpp:60)
==88718==    by 0x117355: main (test-commodities.cpp:196)

+ 5 more
2023-07-20 15:22:56 +01:00