Temporary accounts were referenced after deletion
Fixes D53C98E5-506D-4CE5-91A3-7666FD33B65B
This commit is contained in:
parent
9061db8e47
commit
57abfd7ef8
2 changed files with 20 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ post_t& temporaries_t::copy_post(post_t& origin, xact_t& xact,
|
|||
post_temps->push_back(origin);
|
||||
post_t& temp(post_temps->back());
|
||||
|
||||
temp.add_flags(ITEM_TEMP);
|
||||
if (account)
|
||||
temp.account = account;
|
||||
temp.add_flags(ITEM_TEMP);
|
||||
|
||||
temp.account->add_post(&temp);
|
||||
xact.add_post(&temp);
|
||||
|
|
@ -109,8 +109,8 @@ post_t& temporaries_t::create_post(xact_t& xact, account_t * account)
|
|||
post_temps->push_back(post_t(account));
|
||||
post_t& temp(post_temps->back());
|
||||
|
||||
temp.account = account;
|
||||
temp.add_flags(ITEM_TEMP);
|
||||
temp.account = account;
|
||||
|
||||
temp.account->add_post(&temp);
|
||||
xact.add_post(&temp);
|
||||
|
|
@ -127,10 +127,10 @@ account_t& temporaries_t::create_account(const string& name,
|
|||
acct_temps->push_back(account_t(parent, name));
|
||||
account_t& temp(acct_temps->back());
|
||||
|
||||
temp.add_flags(ACCOUNT_TEMP);
|
||||
if (parent)
|
||||
parent->add_account(&temp);
|
||||
|
||||
temp.add_flags(ACCOUNT_TEMP);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue