diff options
author | John Wiegley <johnw@newartisans.com> | 2014-04-14 11:08:26 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2014-04-14 11:08:26 -0500 |
commit | 0d23e3d4f6ea4e9ec9a70211abb892383b80188e (patch) | |
tree | 1c2d81ce53dd00c6c06a96ea9d41984fd7e3b385 /src | |
parent | 57870f1be87383bf1bc3d7d9a06e411546fb6801 (diff) | |
download | fork-ledger-0d23e3d4f6ea4e9ec9a70211abb892383b80188e.tar.gz fork-ledger-0d23e3d4f6ea4e9ec9a70211abb892383b80188e.tar.bz2 fork-ledger-0d23e3d4f6ea4e9ec9a70211abb892383b80188e.zip |
Apply any outstanding deferred postings at the end of parsing
Diffstat (limited to 'src')
-rw-r--r-- | src/account.cc | 15 | ||||
-rw-r--r-- | src/account.h | 1 | ||||
-rw-r--r-- | src/journal.cc | 1 | ||||
-rw-r--r-- | src/textual.cc | 3 |
4 files changed, 20 insertions, 0 deletions
diff --git a/src/account.cc b/src/account.cc index a702cf11..216b15bd 100644 --- a/src/account.cc +++ b/src/account.cc @@ -154,6 +154,21 @@ void account_t::add_deferred_post(const string& uuid, post_t * post) } } +void account_t::apply_deferred_posts() +{ + if (deferred_posts) { + foreach (deferred_posts_map_t::value_type& pair, *deferred_posts) { + foreach (post_t * post, pair.second) + post->account->add_post(post); + } + deferred_posts = none; + } + + // Also apply in child accounts + foreach (const accounts_map::value_type& pair, accounts) + pair.second->apply_deferred_posts(); +} + bool account_t::remove_post(post_t * post) { // It's possible that 'post' wasn't yet in this account, but try to diff --git a/src/account.h b/src/account.h index 3ce93fba..d1377c39 100644 --- a/src/account.h +++ b/src/account.h @@ -139,6 +139,7 @@ public: void add_post(post_t * post); void add_deferred_post(const string& uuid, post_t * post); + void apply_deferred_posts(); bool remove_post(post_t * post); posts_list::iterator posts_begin() { diff --git a/src/journal.cc b/src/journal.cc index 94a535d7..ea74cb66 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -399,6 +399,7 @@ bool journal_t::add_xact(xact_t * xact) if (i != acct->deferred_posts->end()) { foreach (post_t * rpost, (*i).second) acct->add_post(rpost); + acct->deferred_posts->erase(i); } } } diff --git a/src/textual.cc b/src/textual.cc index 6f8f0492..d02e2f79 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1925,6 +1925,9 @@ std::size_t journal_t::read_textual(parse_context_stack_t& context_stack) } TRACE_STOP(parsing_total, 1); + // Apply any deferred postings at this time + master->apply_deferred_posts(); + // These tracers were started in textual.cc TRACE_FINISH(xact_text, 1); TRACE_FINISH(xact_details, 1); |