From 9159e65a9d689eb9ffd513205ad708aaa2e6d403 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sun, 12 Apr 1998 19:05:25 +0000 Subject: [PATCH] error checking for insert-split git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@799 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Transaction.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index a5629f1760..10bf08b517 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -535,11 +535,20 @@ xaccTransAppendSplit (Transaction *trans, Split *split) { int i, num; Split **oldarray; + Transaction *oldtrans; if (!trans) return; if (!split) return; + + /* first, make sure that the split isn't already inserted + * elsewhere. If so, then remove it. */ + oldtrans = split->parent; + if (oldtrans) { + xaccTransRemoveSplit (oldtrans, split); + xaccTransRebalance (oldtrans); + } - /* first, insert the split into the array */ + /* now, insert the split into the array */ split->parent = trans; num = xaccCountSplits (trans->splits);