gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Fri Sep 15 17:27:13 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/96a63f92 (commit)
via https://github.com/Gnucash/gnucash/commit/c4419460 (commit)
via https://github.com/Gnucash/gnucash/commit/34564ef6 (commit)
via https://github.com/Gnucash/gnucash/commit/8277f4d5 (commit)
via https://github.com/Gnucash/gnucash/commit/0056e5f0 (commit)
via https://github.com/Gnucash/gnucash/commit/235e24a0 (commit)
via https://github.com/Gnucash/gnucash/commit/db77fb81 (commit)
from https://github.com/Gnucash/gnucash/commit/69149514 (commit)
commit 96a63f922f7e3ce141ca059806e5b968986323e3
Merge: 69149514b5 c44194606a
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Sep 16 05:26:41 2023 +0800
Merge branch 'plug-test-leaks' into stable #1771
commit c44194606a6bc68a0ae22e7ca68c5d22592ae3cd
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Sep 15 23:32:29 2023 +0800
[test-xml-pricedb] free a sixtp parser
diff --git a/libgnucash/backend/xml/test/test-xml-pricedb.cpp b/libgnucash/backend/xml/test/test-xml-pricedb.cpp
index 0b625b7e54..ae9d687055 100644
--- a/libgnucash/backend/xml/test/test-xml-pricedb.cpp
+++ b/libgnucash/backend/xml/test/test-xml-pricedb.cpp
@@ -114,6 +114,7 @@ test_db (GNCPriceDB* db)
failure_args ("gnc_xml_parse_file returned FALSE",
__FILE__, __LINE__, "%d", iter);
}
+ sixtp_destroy (parser);
}
g_unlink (filename1);
commit 34564ef6d04b2a64cc402e9d47fa56fd6ad8b084
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Sep 15 22:12:58 2023 +0800
[test-qofobject] plug some leaks
diff --git a/libgnucash/engine/test/test-qofobject.c b/libgnucash/engine/test/test-qofobject.c
index ebe82d7ded..fae1379587 100644
--- a/libgnucash/engine/test/test-qofobject.c
+++ b/libgnucash/engine/test/test-qofobject.c
@@ -303,6 +303,7 @@ test_qof_object_book_begin( Fixture *fixture, gconstpointer pData )
g_assert_cmpint( g_list_index( get_book_list(), (gconstpointer) book2 ), != , -1 );
g_assert_cmpint( object_book_begin_struct.call_count, == , list_length );
+ qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
qof_book_destroy( book2 );
}
@@ -333,6 +334,7 @@ test_qof_object_book_end( Fixture *fixture, gconstpointer pData )
qof_book_destroy( book2 ); /* calls object_book_end */
g_assert_cmpint( object_book_begin_struct.call_count, == , list_length );
g_assert_cmpint( 0, == , g_list_length( get_book_list() ) );
+ qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
}
static struct
@@ -387,6 +389,7 @@ test_qof_object_is_dirty( Fixture *fixture, gconstpointer pData )
g_assert_true( qof_object_is_dirty( book ) == TRUE );
g_assert_cmpint( object_dirty_struct.call_count, == , 1 ); /* should break on first */
+ qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
qof_book_destroy( book );
}
@@ -430,6 +433,7 @@ test_qof_object_mark_clean( Fixture *fixture, gconstpointer pData )
qof_object_mark_clean( book );
g_assert_cmpint( object_mark_clean_struct.call_count, == , list_length );
+ qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
qof_book_destroy( book );
}
@@ -558,6 +562,7 @@ test_qof_object_foreach_type( Fixture *fixture, gconstpointer pData )
foreach_type_cb_struct.call_count = 0;
qof_object_foreach_type( mock_foreach_type_cb, ( gpointer ) &user_data );
g_assert_cmpint( foreach_type_cb_struct.call_count, == , list_length );
+ qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
}
static struct
@@ -680,7 +685,7 @@ test_qof_object_foreach_sorted( Fixture *fixture, gconstpointer pData )
g_assert_cmpint( list_length, == , foreach_for_sorted_struct.call_count );
qof_book_destroy( book );
- g_list_free( foreach_for_sorted_struct.instances );
+ g_list_free_full (foreach_for_sorted_struct.instances, g_object_unref);
}
void
commit 8277f4d559f15f6c2bdbf791f6ffda0e7d8044b7
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Sep 15 22:08:01 2023 +0800
[test-qofbook] plug leaks
diff --git a/libgnucash/engine/test/test-qofbook.c b/libgnucash/engine/test/test-qofbook.c
index 59b6431a70..2826b62b28 100644
--- a/libgnucash/engine/test/test-qofbook.c
+++ b/libgnucash/engine/test/test-qofbook.c
@@ -330,9 +330,10 @@ test_book_get_counter( Fixture *fixture, gconstpointer pData )
counter = qof_book_get_counter( fixture->book, counter_name );
g_assert_cmpint( counter, == , 0 );
- qof_book_increment_and_format_counter( fixture->book, counter_name );
+ char *r = qof_book_increment_and_format_counter( fixture->book, counter_name );
counter = qof_book_get_counter( fixture->book, counter_name );
g_assert_cmpint( counter, == , 1 );
+ g_free (r);
}
static void
@@ -341,7 +342,7 @@ test_book_get_counter_format ( Fixture *fixture, gconstpointer pData )
const char *counter_name = "Counter name";
const char *err_no_book = "No book";
const char *err_invalid_cnt = "Invalid counter name";
- const char *r;
+ char *r;
/* need this as long as we have fatal warnings enabled */
g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )handle_faults, NULL );
@@ -367,10 +368,12 @@ test_book_get_counter_format ( Fixture *fixture, gconstpointer pData )
g_test_message( "Testing counter format with existing counter" );
r = qof_book_get_counter_format( fixture->book, counter_name );
g_assert_cmpstr( r, == , "%.6" PRIi64);
+ g_free (r);
g_test_message( "Testing counter format for default value" );
r = qof_book_get_counter_format( fixture->book, counter_name );
g_assert_cmpstr( r, == , "%.6" PRIi64);
+ g_free (r);
}
static void
@@ -379,8 +382,7 @@ test_book_increment_and_format_counter ( Fixture *fixture, gconstpointer pData )
const char *counter_name = "Counter name";
const char *err_no_book = "No book";
const char *err_invalid_cnt = "Invalid counter name";
- const char *format;
- char *r;
+ char *r, *format, *format_str;
gint64 counter;
/* need this as long as we have fatal warnings enabled */
@@ -411,18 +413,24 @@ test_book_increment_and_format_counter ( Fixture *fixture, gconstpointer pData )
r = qof_book_increment_and_format_counter( fixture->book, counter_name );
counter = qof_book_get_counter( fixture->book, counter_name );
format = qof_book_get_counter_format( fixture->book, counter_name );
+ format_str = g_strdup_printf (format, counter);
g_assert_cmpint( counter, == , 1 );
g_assert_true( qof_instance_is_dirty (QOF_INSTANCE (fixture->book)) );
- g_assert_cmpstr( r, == , g_strdup_printf( format, counter ));
+ g_assert_cmpstr( r, == , format_str);
g_free( r );
+ g_free (format);
+ g_free (format_str);
g_test_message( "Testing increment and format with existing counter" );
r = qof_book_increment_and_format_counter( fixture->book, counter_name );
counter = qof_book_get_counter( fixture->book, counter_name );
format = qof_book_get_counter_format( fixture->book, counter_name );
+ format_str = g_strdup_printf (format, counter);
g_assert_cmpint( counter, == , 2 );
- g_assert_cmpstr( r, == , g_strdup_printf( format, counter ));
+ g_assert_cmpstr( r, == , format_str);
g_free( r );
+ g_free (format);
+ g_free (format_str);
}
static void
@@ -494,7 +502,7 @@ test_book_set_default_report ( Fixture *fixture, gconstpointer pData )
const char *test_guid1 = "5123a759ceb9483abf2182d01c140eff";
const char *test_guid2 = "5123a759ceb9483abf2182d01c140eee";
const char *test_name = "My Invoice Report";
- const char *r;
+ char *r;
/* need this as long as we have fatal warnings enabled */
g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )handle_faults, NULL );
@@ -524,15 +532,19 @@ test_book_set_default_report ( Fixture *fixture, gconstpointer pData )
qof_book_set_default_invoice_report ( fixture->book, test_guid1, "" );
r = qof_book_get_default_invoice_report_guid ( fixture->book );
g_assert_cmpstr( r, == , test_guid1 );
+ g_free (r);
r = qof_book_get_default_invoice_report_name ( fixture->book );
g_assert_cmpstr( r, == , "" );
+ g_free (r);
g_test_message( "Testing setting default report with guid and name" );
qof_book_set_default_invoice_report ( fixture->book, test_guid2, test_name );
r = qof_book_get_default_invoice_report_guid ( fixture->book );
g_assert_cmpstr( r, == , test_guid2 );
+ g_free (r);
r = qof_book_get_default_invoice_report_name ( fixture->book );
g_assert_cmpstr( r, == , test_name );
+ g_free (r);
}
static void
commit 0056e5f091f47a00c4aacb9d4db269005f9966c7
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Sep 15 21:39:39 2023 +0800
[gtest-import-map] plug leaks
diff --git a/libgnucash/engine/test/gtest-import-map.cpp b/libgnucash/engine/test/gtest-import-map.cpp
index e0938eed4e..54980e6338 100644
--- a/libgnucash/engine/test/gtest-import-map.cpp
+++ b/libgnucash/engine/test/gtest-import-map.cpp
@@ -266,6 +266,8 @@ TEST_F(ImapBayesTest, FindAccountBayes)
root->set_path({std::string{IMAP_FRAME_BAYES} + "/" + pepper + "/" + waldo + "/" + acct2_guid}, new KvpValue{*value});
account = gnc_account_imap_find_account_bayes(t_acc, t_list3);
EXPECT_EQ(t_expense_account1, account);
+ g_free (acct1_guid);
+ g_free (acct2_guid);
}
TEST_F(ImapBayesTest, AddAccountBayes)
@@ -309,6 +311,8 @@ TEST_F(ImapBayesTest, AddAccountBayes)
qof_instance_reset_editlevel(QOF_INSTANCE(t_bank_account));
value = root->get_slot({std::string{IMAP_FRAME_BAYES} + "/" + baz + "/" + acct2_guid});
EXPECT_EQ(2, value->get<int64_t>());
+ g_free (acct1_guid);
+ g_free (acct2_guid);
}
TEST_F(ImapBayesTest, ConvertBayesData)
@@ -353,6 +357,10 @@ TEST_F(ImapBayesTest, ConvertBayesData)
value = root->get_slot({std::string{IMAP_FRAME_BAYES} + "/" + salt + "/" + acct1_guid});
EXPECT_EQ(10, value->get<int64_t>());
EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
+ g_free (acct1_guid);
+ g_free (acct2_guid);
+ g_free (acct3_guid);
+ g_free (acct4_guid);
}
/* Tests the import map's handling of KVP delimiters */
@@ -365,6 +373,7 @@ TEST_F (ImapBayesTest, import_map_with_delimiters)
gnc_account_imap_add_account_bayes (t_acc, tokens, t_expense_account1);
auto account = gnc_account_imap_find_account_bayes (t_acc, tokens);
EXPECT_EQ (account, t_expense_account1);
+ g_list_free (tokens);
}
TEST_F (ImapBayesTest, get_bayes_info)
@@ -383,5 +392,8 @@ TEST_F (ImapBayesTest, get_bayes_info)
EXPECT_STREQ (info->head, (std::string {IMAP_FRAME_BAYES} + "/one/two/three/" + acct1_guid).c_str ());
EXPECT_STREQ (info->match_string, "one/two/three");
EXPECT_STREQ (info->count, "1");
+ g_list_free_full (infos, (GDestroyNotify)gnc_account_imap_info_destroy);
+ g_list_free (tokens);
+ g_free (acct1_guid);
}
commit 235e24a055634b476fbca9bd5e2dbff89e816f7b
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Sep 15 21:38:59 2023 +0800
[account.cpp] ~GncImapInfo = gnc_account_imap_info_destroy
diff --git a/gnucash/gnome/dialog-imap-editor.c b/gnucash/gnome/dialog-imap-editor.c
index 8c9d31025e..581ef2c766 100644
--- a/gnucash/gnome/dialog-imap-editor.c
+++ b/gnucash/gnome/dialog-imap-editor.c
@@ -647,17 +647,10 @@ get_imap_info (ImapDialog *imap_dialog, Account *acc, const gchar *category, con
// First add a child entry and pass iter to add_to_store
gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), &child, &toplevel);
add_to_store (imap_dialog, &child, text, imapInfo);
-
- // Free the members and structure
- g_free (imapInfo->head);
- g_free (imapInfo->category);
- g_free (imapInfo->match_string);
- g_free (imapInfo->count);
- g_free (imapInfo);
}
}
g_free (acc_name);
- g_list_free (imap_list); // Free the List
+ g_list_free_full (imap_list, (GDestroyNotify)gnc_account_imap_info_destroy); // Free the List
}
static void
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index b0bd8a8937..1a53ff6026 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -6232,6 +6232,15 @@ build_bayes (const char *suffix, KvpValue * value, GncImapInfo & imapInfo)
imapInfo.list = g_list_prepend (imapInfo.list, imap_node);
}
+void gnc_account_imap_info_destroy (GncImapInfo* imapInfo)
+{
+ g_free (imapInfo->head);
+ g_free (imapInfo->category);
+ g_free (imapInfo->match_string);
+ g_free (imapInfo->count);
+ g_free (imapInfo);
+}
+
GList *
gnc_account_imap_get_info_bayes (Account *acc)
{
diff --git a/libgnucash/engine/Account.h b/libgnucash/engine/Account.h
index 342c236c1f..f1db851cf4 100644
--- a/libgnucash/engine/Account.h
+++ b/libgnucash/engine/Account.h
@@ -1611,6 +1611,11 @@ typedef enum
char *count;
}GncImapInfo;
+ /** Clean destructor for the imap_info structure of Bayesian
+ * mappings
+ */
+ void gnc_account_imap_info_destroy (GncImapInfo*);
+
/** Returns a GList of structure imap_info of all Bayesian mappings for
* required Account
*/
commit db77fb81a5abb133c8576cf9da96fad2c6e5fb6a
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Sep 15 21:07:34 2023 +0800
[test-job] plug leaks
diff --git a/libgnucash/engine/test/test-job.c b/libgnucash/engine/test/test-job.c
index 737f168017..70a8448809 100644
--- a/libgnucash/engine/test/test-job.c
+++ b/libgnucash/engine/test/test-job.c
@@ -135,12 +135,14 @@ test_job (void)
do_test (g_list_length (list) == 1, "correct joblist length");
do_test (list->data == job, "verify job in list");
gncJobSetActive (job, FALSE);
+ g_list_free (list);
list = gncCustomerGetJoblist (cust, FALSE);
do_test (list == NULL, "no active jobs");
list = gncCustomerGetJoblist (cust, TRUE);
do_test (list != NULL, "all jobs");
gncJobBeginEdit (job);
gncJobDestroy (job);
+ g_list_free (list);
list = gncCustomerGetJoblist (cust, TRUE);
do_test (list == NULL, "no more jobs");
}
@@ -171,6 +173,8 @@ test_string_fcn (QofBook *book, const char *message,
do_test (g_strcmp0 (get (job), str) == 0, message);
g_free (str);
gncJobSetActive (job, FALSE);
+ gncJobBeginEdit (job);
+ gncJobDestroy (job);
count++;
}
@@ -196,6 +200,8 @@ test_numeric_fcn (QofBook *book, const char *message,
// do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
do_test (gnc_numeric_equal (get (job), num), message);
gncJobSetActive (job, FALSE);
+ gncJobBeginEdit (job);
+ gncJobDestroy (job);
count++;
}
@@ -223,6 +229,8 @@ test_bool_fcn (QofBook *book, const char *message,
// do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
do_test (get (job) == num, message);
gncJobSetActive (job, FALSE);
+ gncJobBeginEdit (job);
+ gncJobDestroy (job);
count++;
}
Summary of changes:
gnucash/gnome/dialog-imap-editor.c | 9 +-------
libgnucash/backend/xml/test/test-xml-pricedb.cpp | 1 +
libgnucash/engine/Account.cpp | 9 ++++++++
libgnucash/engine/Account.h | 5 +++++
libgnucash/engine/test/gtest-import-map.cpp | 12 +++++++++++
libgnucash/engine/test/test-job.c | 8 ++++++++
libgnucash/engine/test/test-qofbook.c | 26 +++++++++++++++++-------
libgnucash/engine/test/test-qofobject.c | 7 ++++++-
8 files changed, 61 insertions(+), 16 deletions(-)
More information about the gnucash-changes
mailing list