Skip to content

Commit

Permalink
Replace check_open() in setter API with internal qof_{begin,commit}_…
Browse files Browse the repository at this point in the history
…edit().

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13130 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
spot committed Feb 6, 2006
1 parent be29e4e commit fccb17f
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/engine/Transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr)
gint fraction, old_fraction;

if (!trans || !curr || trans->common_currency == curr) return;
check_open (trans);
qof_begin_edit(QOF_INSTANCE(trans));

old_fraction = gnc_commodity_get_fraction (trans->common_currency);
trans->common_currency = curr;
Expand All @@ -1645,6 +1645,7 @@ xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr)
}

mark_trans (trans);
qof_commit_edit(QOF_INSTANCE(trans));
}

/********************************************************************\
Expand Down Expand Up @@ -1673,12 +1674,13 @@ void
xaccTransDestroy (Transaction *trans)
{
if (!trans) return;
check_open (trans);

if (xaccTransGetReadOnly (trans) &&
!qof_book_shutting_down(trans->inst.book)) return;

trans->inst.do_free = TRUE;
if (!xaccTransGetReadOnly (trans) ||
qof_book_shutting_down(trans->inst.book)) {
qof_begin_edit(QOF_INSTANCE(trans));
trans->inst.do_free = TRUE;
qof_commit_edit(QOF_INSTANCE(trans));
}
}

static void
Expand Down Expand Up @@ -2181,7 +2183,8 @@ xaccTransAppendSplit (Transaction *trans, Split *split)
{
if (!trans || !split) return;
g_return_if_fail (trans->inst.book == split->book);
check_open (trans);

qof_begin_edit(QOF_INSTANCE(trans));

/* First, make sure that the split isn't already inserted
* elsewhere. If so, then remove it. */
Expand Down Expand Up @@ -2209,6 +2212,7 @@ xaccTransAppendSplit (Transaction *trans, Split *split)
split->value = new_value;
SET_GAINS_VDIRTY(split);
}
qof_commit_edit(QOF_INSTANCE(trans));
}

/********************************************************************\
Expand Down Expand Up @@ -2498,14 +2502,15 @@ xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb)
static inline void
xaccTransSetDateInternal(Transaction *trans, Timespec *dadate, Timespec val)
{
check_open(trans);
qof_begin_edit(QOF_INSTANCE(trans));

PINFO ("addr=%p set date to %llu.%09ld %s",
trans, val.tv_sec, val.tv_nsec,
ctime (({time_t secs = (time_t) val.tv_sec; &secs;})));

*dadate = val;
mark_trans(trans);
qof_commit_edit(QOF_INSTANCE(trans));

/* Because the date has changed, we need to make sure that each of
* the splits is properly ordered in each of their accounts. We
Expand Down Expand Up @@ -2638,13 +2643,11 @@ qofTransSetNum (Transaction *trans, const char *xnum)
void
xaccTransSetNum (Transaction *trans, const char *xnum)
{
char * tmp;
if (!trans || !xnum) return;
check_open (trans);
qof_begin_edit(QOF_INSTANCE(trans));

tmp = gnc_string_cache_insert((gpointer) xnum);
gnc_string_cache_remove(trans->num);
trans->num = tmp;
CACHE_REPLACE(trans->num, xnum);
qof_commit_edit(QOF_INSTANCE(trans));
}

static void
Expand All @@ -2658,13 +2661,11 @@ qofTransSetDescription (Transaction *trans, const char *desc)
void
xaccTransSetDescription (Transaction *trans, const char *desc)
{
char * tmp;
if (!trans || !desc) return;
check_open (trans);
qof_begin_edit(QOF_INSTANCE(trans));

tmp = gnc_string_cache_insert((gpointer) desc);
gnc_string_cache_remove(trans->description);
trans->description = tmp;
CACHE_REPLACE(trans->description, desc);
qof_commit_edit(QOF_INSTANCE(trans));
}

static void
Expand All @@ -2679,9 +2680,10 @@ void
xaccTransSetNotes (Transaction *trans, const char *notes)
{
if (!trans || !notes) return;
check_open (trans);
qof_begin_edit(QOF_INSTANCE(trans));

kvp_frame_set_str (trans->inst.kvp_data, trans_notes_str, notes);
qof_commit_edit(QOF_INSTANCE(trans));
}

/********************************************************************\
Expand Down

0 comments on commit fccb17f

Please sign in to comment.