Corrected a lingering reference to a temporary

Fixes: CEE57FBC-DF19-40DD-901D-68B1AEC29888
This commit is contained in:
John Wiegley 2011-02-10 23:00:18 -05:00
parent a8b02cacd7
commit 21a123e525
2 changed files with 52 additions and 25 deletions

View file

@ -465,7 +465,7 @@ void collapse_posts::report_subtotal()
DEBUG("filters.collapse", "latest date = " << latest_date);
handle_value(/* value= */ subtotal,
/* account= */ &totals_account,
/* account= */ totals_account,
/* xact= */ &xact,
/* temps= */ temps,
/* handler= */ handler,
@ -523,15 +523,15 @@ display_filter_posts::display_filter_posts(post_handler_ptr handler,
report_t& _report,
bool _show_rounding)
: item_handler<post_t>(handler), report(_report),
show_rounding(_show_rounding),
rounding_account(temps.create_account(_("<Adjustment>"))),
revalued_account(temps.create_account(_("<Revalued>")))
show_rounding(_show_rounding)
{
TRACE_CTOR(display_filter_posts,
"post_handler_ptr, report_t&, account_t&, bool");
display_amount_expr = report.HANDLER(display_amount_).expr;
display_total_expr = report.HANDLER(display_total_).expr;
create_accounts();
}
bool display_filter_posts::output_rounding(post_t& post)
@ -551,7 +551,7 @@ bool display_filter_posts::output_rounding(post_t& post)
// 2. The --empty option was specified
// 3. The account of the posting is <Revalued>
if (post.account == &revalued_account) {
if (post.account == revalued_account) {
if (show_rounding)
last_display_total = new_display_total;
return true;
@ -575,7 +575,7 @@ bool display_filter_posts::output_rounding(post_t& post)
"rounding.diff = " << diff);
handle_value(/* value= */ diff,
/* account= */ &rounding_account,
/* account= */ rounding_account,
/* xact= */ post.xact,
/* temps= */ temps,
/* handler= */ handler,
@ -608,8 +608,6 @@ changed_value_posts::changed_value_posts
: item_handler<post_t>(handler), report(_report),
for_accounts_report(_for_accounts_report),
show_unrealized(_show_unrealized), last_post(NULL),
revalued_account(_display_filter ? _display_filter->revalued_account :
temps.create_account(_("<Revalued>"))),
display_filter(_display_filter)
{
TRACE_CTOR(changed_value_posts, "post_handler_ptr, report_t&, bool");
@ -637,6 +635,8 @@ changed_value_posts::changed_value_posts
losses_equity_account =
report.session.journal->master->find_account(losses_equity_account_name);
losses_equity_account->add_flags(ACCOUNT_GENERATED);
create_accounts();
}
void changed_value_posts::flush()
@ -682,7 +682,7 @@ void changed_value_posts::output_revaluation(post_t& post, const date_t& date)
if (! for_accounts_report) {
handle_value
(/* value= */ diff,
/* account= */ &revalued_account,
/* account= */ revalued_account,
/* xact= */ &xact,
/* temps= */ temps,
/* handler= */ handler,
@ -954,7 +954,7 @@ void interval_posts::operator()(post_t& post)
xact_t& null_xact = temps.create_xact();
null_xact._date = last_interval.inclusive_end();
post_t& null_post = temps.create_post(null_xact, &empty_account);
post_t& null_post = temps.create_post(null_xact, empty_account);
null_post.add_flags(POST_CALCULATED);
null_post.amount = 0L;

View file

@ -411,7 +411,7 @@ class collapse_posts : public item_handler<post_t>
xact_t * last_xact;
post_t * last_post;
temporaries_t temps;
account_t& totals_account;
account_t * totals_account;
bool only_collapse_if_zero;
std::list<post_t *> component_posts;
report_t& report;
@ -429,14 +429,18 @@ public:
display_predicate(_display_predicate),
only_predicate(_only_predicate), count(0),
last_xact(NULL), last_post(NULL),
totals_account(temps.create_account(_("<Total>"))),
only_collapse_if_zero(_only_collapse_if_zero), report(_report) {
TRACE_CTOR(collapse_posts, "post_handler_ptr, ...");
create_accounts();
}
virtual ~collapse_posts() {
TRACE_DTOR(collapse_posts);
}
void create_accounts() {
totals_account = &temps.create_account(_("<Total>"));
}
virtual void flush() {
report_subtotal();
item_handler<post_t>::flush();
@ -457,6 +461,7 @@ public:
last_post = NULL;
temps.clear();
create_accounts();
component_posts.clear();
item_handler<post_t>::clear();
@ -505,12 +510,12 @@ class display_filter_posts : public item_handler<post_t>
bool show_rounding;
value_t last_display_total;
temporaries_t temps;
account_t& rounding_account;
account_t * rounding_account;
display_filter_posts();
public:
account_t& revalued_account;
account_t * revalued_account;
display_filter_posts(post_handler_ptr handler,
report_t& _report,
@ -520,6 +525,11 @@ public:
TRACE_DTOR(display_filter_posts);
}
void create_accounts() {
rounding_account = &temps.create_account(_("<Adjustment>"));
revalued_account = &temps.create_account(_("<Revalued>"));
}
bool output_rounding(post_t& post);
virtual void operator()(post_t& post);
@ -531,6 +541,7 @@ public:
last_display_total = value_t();
temps.clear();
create_accounts();
item_handler<post_t>::clear();
}
@ -551,7 +562,7 @@ class changed_value_posts : public item_handler<post_t>
value_t last_total;
value_t repriced_total;
temporaries_t temps;
account_t& revalued_account;
account_t * revalued_account;
account_t * gains_equity_account;
account_t * losses_equity_account;
@ -570,6 +581,11 @@ public:
TRACE_DTOR(changed_value_posts);
}
void create_accounts() {
revalued_account = (display_filter ? display_filter->revalued_account :
&temps.create_account(_("<Revalued>")));
}
virtual void flush();
void output_revaluation(post_t& post, const date_t& current);
@ -585,6 +601,7 @@ public:
last_total = value_t();
temps.clear();
create_accounts();
item_handler<post_t>::clear();
}
@ -666,7 +683,7 @@ class interval_posts : public subtotal_posts
date_interval_t interval;
date_interval_t last_interval;
post_t * last_post;
account_t& empty_account;
account_t * empty_account;
bool exact_periods;
bool generate_empty_posts;
@ -681,16 +698,20 @@ public:
bool _generate_empty_posts = false)
: subtotal_posts(_handler, amount_expr), start_interval(_interval),
interval(start_interval), last_post(NULL),
empty_account(temps.create_account(_("<None>"))),
exact_periods(_exact_periods),
generate_empty_posts(_generate_empty_posts) {
TRACE_CTOR(interval_posts,
"post_handler_ptr, expr_t&, date_interval_t, bool, bool");
create_accounts();
}
virtual ~interval_posts() throw() {
TRACE_DTOR(interval_posts);
}
void create_accounts() {
empty_account = &temps.create_account(_("<None>"));
}
void report_subtotal(const date_interval_t& interval);
virtual void flush() {
@ -707,29 +728,34 @@ public:
last_interval = date_interval_t();
last_post = NULL;
item_handler<post_t>::clear();
subtotal_posts::clear();
create_accounts();
}
};
class posts_as_equity : public subtotal_posts
{
post_t * last_post;
account_t& equity_account;
account_t * equity_account;
account_t * balance_account;
posts_as_equity();
public:
posts_as_equity(post_handler_ptr _handler, expr_t& amount_expr)
: subtotal_posts(_handler, amount_expr),
equity_account(temps.create_account(_("Equity"))) {
: subtotal_posts(_handler, amount_expr) {
TRACE_CTOR(posts_as_equity, "post_handler_ptr, expr_t&");
balance_account = equity_account.find_account(_("Opening Balances"));
create_accounts();
}
virtual ~posts_as_equity() throw() {
TRACE_DTOR(posts_as_equity);
}
void create_accounts() {
equity_account = &temps.create_account(_("Equity"));
balance_account = equity_account->find_account(_("Opening Balances"));
}
void report_subtotal();
virtual void flush() {
@ -739,7 +765,8 @@ public:
virtual void clear() {
last_post = NULL;
item_handler<post_t>::clear();
subtotal_posts::clear();
create_accounts();
}
};
@ -837,7 +864,7 @@ public:
for (int i = 0; i < 7; i++)
days_of_the_week[i].clear();
item_handler<post_t>::clear();
subtotal_posts::clear();
}
};
@ -928,7 +955,7 @@ class forecast_posts : public generate_posts
virtual void clear() {
pred.mark_uncompiled();
item_handler<post_t>::clear();
generate_posts::clear();
}
};