Skip to content

Commit

Permalink
Bug 797895 - Hang for a long time (9 minutes per account) importing...
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jralls committed Sep 17, 2020
1 parent 1a50a29 commit 9c8fa5c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions libgnucash/engine/Account.cpp
Expand Up @@ -5540,7 +5540,7 @@ convert_entry (KvpEntry entry, Account* root)
}

static std::vector<FlatKvpEntry>
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});
Expand All @@ -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;
Expand Down

0 comments on commit 9c8fa5c

Please sign in to comment.