diff options
author | John Wiegley <johnw@newartisans.com> | 2010-05-22 13:08:53 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-05-22 21:33:47 -0400 |
commit | 57abfd7ef8b4500b7a0c14d136d397ecf974163b (patch) | |
tree | 434c8b0538ba3fc80649feea284f5bd065bb30bb /src/account.cc | |
parent | 9061db8e47d06db8502febafd202e44b2f9213ba (diff) | |
download | fork-ledger-57abfd7ef8b4500b7a0c14d136d397ecf974163b.tar.gz fork-ledger-57abfd7ef8b4500b7a0c14d136d397ecf974163b.tar.bz2 fork-ledger-57abfd7ef8b4500b7a0c14d136d397ecf974163b.zip |
Temporary accounts were referenced after deletion
Fixes D53C98E5-506D-4CE5-91A3-7666FD33B65B
Diffstat (limited to 'src/account.cc')
-rw-r--r-- | src/account.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/account.cc b/src/account.cc index e02d21d7..46f37091 100644 --- a/src/account.cc +++ b/src/account.cc @@ -43,8 +43,16 @@ account_t::~account_t() TRACE_DTOR(account_t); foreach (accounts_map::value_type& pair, accounts) - if (! pair.second->has_flags(ACCOUNT_TEMP)) + if (! pair.second->has_flags(ACCOUNT_TEMP) || + has_flags(ACCOUNT_TEMP)) checked_delete(pair.second); + + foreach (post_t * post, posts) { + if (post->account) { + assert(post->account == this); + post->account = NULL; + } + } } account_t * account_t::find_account(const string& name, @@ -79,6 +87,14 @@ account_t * account_t::find_account(const string& name, return NULL; account = new account_t(this, first); + + // An account created within a temporary or generated account is itself + // temporary or generated, so that the whole tree has the same status. + if (has_flags(ACCOUNT_TEMP)) + account->add_flags(ACCOUNT_TEMP); + if (has_flags(ACCOUNT_GENERATED)) + account->add_flags(ACCOUNT_GENERATED); + std::pair<accounts_map::iterator, bool> result = accounts.insert(accounts_map::value_type(first, account)); assert(result.second); |