Bug 798535 - Crash when increasing the number of periods in a budget

because in the SQL backend, gnc_budget_commit_edit will update the sql
by reading from vectors with an increased priv->num_periods.
This commit is contained in:
Christopher Lam 2022-05-18 17:37:05 +08:00
parent 29f2c7c399
commit 670902d5a8

View File

@ -476,15 +476,14 @@ gnc_budget_set_num_periods(GncBudget* budget, guint num_periods)
gnc_budget_begin_edit(budget);
priv->num_periods = num_periods;
qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget);
std::for_each (priv->acct_map->begin(),
priv->acct_map->end(),
[num_periods](auto& it)
{
it.second.resize(num_periods);
});
qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget);
qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL);
}