[account.cpp] fix regression caused by 3f7a5a8267

whereby deleting an account and moving all splits to another account
would segfault. make a copy of priv->splits and work on the copy
rather than the original.
This commit is contained in:
Christopher Lam 2024-05-13 12:42:26 +08:00
parent e54e9d8086
commit 7b46466ebd

View File

@ -2251,8 +2251,8 @@ xaccAccountMoveAllSplits (Account *accfrom, Account *accto)
* Convert each split's amount to accto's commodity.
* Commit to editing each transaction.
*/
std::for_each (from_priv->splits.begin(), from_priv->splits.end(),
[accto](Split *s){ xaccPostSplitMove (s, accto); });
auto splits = from_priv->splits;
std::for_each (splits.begin(), splits.end(), [accto](auto s){ xaccPostSplitMove (s, accto); });
/* Finally empty accfrom. */
g_assert(from_priv->splits.empty());