mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
More consistent Lot<->Split handling. Try to use the right API for adding
a cloned Split to the Lot. Make sure to remove the Split from the Lot when deleting a Split. (This prevents use-after-free by test-lots.) Add some comments to some strange code that's possibly wrong. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13922 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
40a9ed1925
commit
3555d0f101
@ -210,11 +210,9 @@ xaccSplitClone (const Split *s)
|
|||||||
split->inst.kvp_data = kvp_frame_copy(s->inst.kvp_data);
|
split->inst.kvp_data = kvp_frame_copy(s->inst.kvp_data);
|
||||||
|
|
||||||
xaccAccountInsertSplit(s->acc, split);
|
xaccAccountInsertSplit(s->acc, split);
|
||||||
if (s->lot)
|
if (s->lot) {
|
||||||
{
|
/* CHECKME: Is this right? */
|
||||||
/* FIXME: Doesn't look right. */
|
gnc_lot_add_split(s->lot, split);
|
||||||
s->lot->splits = g_list_append (s->lot->splits, split);
|
|
||||||
s->lot->is_closed = -1;
|
|
||||||
}
|
}
|
||||||
return split;
|
return split;
|
||||||
}
|
}
|
||||||
@ -504,16 +502,16 @@ xaccSplitCommitEdit(Split *s)
|
|||||||
|
|
||||||
orig_acc = s->orig_acc;
|
orig_acc = s->orig_acc;
|
||||||
acc = s->acc;
|
acc = s->acc;
|
||||||
|
/* Remove from lot (but only if it hasn't been moved to
|
||||||
|
new lot already) */
|
||||||
|
if (s->lot && (s->lot->account != acc || s->inst.do_free))
|
||||||
|
gnc_lot_remove_split (s->lot, s);
|
||||||
|
|
||||||
/* Possibly remove the split from the original account... */
|
/* Possibly remove the split from the original account... */
|
||||||
if (orig_acc && (orig_acc != acc || s->inst.do_free)) {
|
if (orig_acc && (orig_acc != acc || s->inst.do_free)) {
|
||||||
GList *node = g_list_find (orig_acc->splits, s);
|
GList *node = g_list_find (orig_acc->splits, s);
|
||||||
if (node) {
|
if (node) {
|
||||||
orig_acc->splits = g_list_delete_link (orig_acc->splits, node);
|
orig_acc->splits = g_list_delete_link (orig_acc->splits, node);
|
||||||
/* Remove from lot (but only if it hasn't been moved to
|
|
||||||
new lot already) */
|
|
||||||
if (s->lot && s->lot->account == orig_acc)
|
|
||||||
gnc_lot_remove_split (s->lot, s);
|
|
||||||
//FIXME: probably not needed.
|
//FIXME: probably not needed.
|
||||||
xaccGroupMarkNotSaved (orig_acc->parent);
|
xaccGroupMarkNotSaved (orig_acc->parent);
|
||||||
//FIXME: find better event type
|
//FIXME: find better event type
|
||||||
@ -642,10 +640,7 @@ xaccSplitDetermineGainStatus (Split *split)
|
|||||||
val = kvp_frame_get_slot (split->inst.kvp_data, "gains-source");
|
val = kvp_frame_get_slot (split->inst.kvp_data, "gains-source");
|
||||||
if (!val)
|
if (!val)
|
||||||
{
|
{
|
||||||
// FIXME: This looks bogus.
|
// CHECKME: We leave split->gains_split alone. Is that correct?
|
||||||
other = xaccSplitGetOtherSplit (split);
|
|
||||||
if (other)
|
|
||||||
val = kvp_frame_get_slot (other->inst.kvp_data, "gains-source");
|
|
||||||
split->gains = GAINS_STATUS_A_VDIRTY | GAINS_STATUS_DATE_DIRTY;
|
split->gains = GAINS_STATUS_A_VDIRTY | GAINS_STATUS_DATE_DIRTY;
|
||||||
} else {
|
} else {
|
||||||
QofCollection *col;
|
QofCollection *col;
|
||||||
|
Loading…
Reference in New Issue
Block a user