From 9c8fa5cd2e28af1ab133375bf06be5637820d265 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 17 Sep 2020 14:22:07 -0700 Subject: [PATCH] Bug 797895 - Hang for a long time (9 minutes per account) importing... a QFX file. Bug 797945 - Tools -> Import Map Editor causes GnuCash to lock up. Don't edit and commit the account if it has no BAYES_IMAP slots. Account committing is extremely expensive. --- libgnucash/engine/Account.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index 6c574cf026..10f8b3caca 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -5540,7 +5540,7 @@ convert_entry (KvpEntry entry, Account* root) } static std::vector -get_new_flat_imap (Account * acc) +get_flat_imap (Account * acc) { auto frame = qof_instance_get_slots (QOF_INSTANCE (acc)); auto slot = frame->get_slot ({IMAP_FRAME_BAYES}); @@ -5566,17 +5566,15 @@ convert_imap_account_bayes_to_flat (Account *acc) auto frame = qof_instance_get_slots (QOF_INSTANCE (acc)); if (!frame->get_keys().size()) return false; - auto new_imap = get_new_flat_imap(acc); + auto flat_imap = get_flat_imap(acc); + if (!flat_imap.size ()) + return false; xaccAccountBeginEdit(acc); frame->set({IMAP_FRAME_BAYES}, nullptr); - if (!new_imap.size ()) - { - xaccAccountCommitEdit(acc); - return false; - } - std::for_each(new_imap.begin(), new_imap.end(), [&frame] (FlatKvpEntry const & entry) { - frame->set({entry.first.c_str()}, entry.second); - }); + std::for_each(flat_imap.begin(), flat_imap.end(), + [&frame] (FlatKvpEntry const & entry) { + frame->set({entry.first.c_str()}, entry.second); + }); qof_instance_set_dirty (QOF_INSTANCE (acc)); xaccAccountCommitEdit(acc); return true;