mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Work on moving entity tables into sessions.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5464 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
2813e46549
commit
114b5af306
@ -919,7 +919,7 @@ gnc_account_create_opening_balance (Account *account,
|
||||
xaccAccountBeginEdit (account);
|
||||
xaccAccountBeginEdit (equity_account);
|
||||
|
||||
trans = xaccMallocTransaction ();
|
||||
trans = xaccMallocTransaction (session);
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
|
||||
|
@ -464,19 +464,23 @@ gnc_schedXaction_end_handler(gpointer data_for_children,
|
||||
ag = gnc_book_get_template_group(book);
|
||||
if ( ag == NULL )
|
||||
{
|
||||
PERR( "Error getting template account group from being-parsed Book." );
|
||||
PERR( "Error getting template account group "
|
||||
"from being-parsed Book." );
|
||||
xmlFreeNode( tree );
|
||||
return FALSE;
|
||||
}
|
||||
acct = xaccGetAccountFromName( ag, id );
|
||||
if ( acct == NULL )
|
||||
{
|
||||
PERR( "Error getting template account with name \"%s\"", id );
|
||||
PERR( "Error getting template account "
|
||||
"with name \"%s\"", id );
|
||||
xmlFreeNode( tree );
|
||||
return FALSE;
|
||||
}
|
||||
DEBUG( "Got template account with name \"%s\" for SX with GUID \"%s\"",
|
||||
DEBUG( "Got template account with name \"%s\" for "
|
||||
"SX with GUID \"%s\"",
|
||||
xaccAccountGetName( acct ), id );
|
||||
|
||||
/* FIXME: free existing template account.
|
||||
* HUH????? We only execute this if there isn't
|
||||
* currently an existing template account, don't we?
|
||||
@ -541,12 +545,15 @@ tt_trn_handler( xmlNodePtr node, gpointer data )
|
||||
{
|
||||
gnc_template_xaction_data *txd = data;
|
||||
Transaction *trn;
|
||||
trn = dom_tree_to_transaction( node );
|
||||
|
||||
trn = dom_tree_to_transaction( node, txd->session );
|
||||
|
||||
if ( trn == NULL ) {
|
||||
return FALSE;
|
||||
} else {
|
||||
txd->transactions = g_list_append( txd->transactions, trn );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -573,16 +580,16 @@ gnc_template_transaction_end_handler(gpointer data_for_children,
|
||||
gxpf_data *gdata = global_data;
|
||||
GNCSession *session = gdata->sessiondata;
|
||||
GList *n;
|
||||
gnc_template_xaction_data *txd;
|
||||
gnc_template_xaction_data txd;
|
||||
|
||||
txd = g_new0 (gnc_template_xaction_data, 1);
|
||||
|
||||
txd->session = session;
|
||||
txd.session = session;
|
||||
txd.accts = NULL;
|
||||
txd.transactions = NULL;
|
||||
|
||||
/* the DOM tree will have an account tree [the template group
|
||||
and account] and a list of transactions [which will be
|
||||
members of the template account].
|
||||
|
||||
|
||||
we want to parse through the dom trees for each, placing
|
||||
the null-parent account in the book's template-group slot,
|
||||
the others under it, and the transactions as normal. */
|
||||
@ -597,24 +604,24 @@ gnc_template_transaction_end_handler(gpointer data_for_children,
|
||||
|
||||
g_return_val_if_fail( tree, FALSE );
|
||||
|
||||
successful = dom_tree_generic_parse( tree, tt_dom_handlers, txd );
|
||||
successful = dom_tree_generic_parse( tree, tt_dom_handlers, &txd );
|
||||
|
||||
if ( successful ) {
|
||||
gdata->cb( tag, gdata->parsedata, txd );
|
||||
gdata->cb( tag, gdata->parsedata, &txd );
|
||||
} else {
|
||||
xmlElemDump( stdout, NULL, tree );
|
||||
}
|
||||
|
||||
|
||||
/* cleanup */
|
||||
for ( n = txd->accts; n; n = n->next ) {
|
||||
for ( n = txd.accts; n; n = n->next ) {
|
||||
n->data = NULL;
|
||||
}
|
||||
for ( n = txd->transactions; n; n = n->next ) {
|
||||
for ( n = txd.transactions; n; n = n->next ) {
|
||||
n->data = NULL;
|
||||
}
|
||||
g_list_free( txd->accts );
|
||||
g_list_free( txd->transactions );
|
||||
g_free( txd );
|
||||
g_list_free( txd.accts );
|
||||
g_list_free( txd.transactions );
|
||||
|
||||
xmlFreeNode( tree );
|
||||
|
||||
return successful;
|
||||
@ -623,5 +630,6 @@ gnc_template_transaction_end_handler(gpointer data_for_children,
|
||||
sixtp*
|
||||
gnc_template_transaction_sixtp_parser_create( void )
|
||||
{
|
||||
return sixtp_dom_parser_new( gnc_template_transaction_end_handler, NULL, NULL );
|
||||
return sixtp_dom_parser_new( gnc_template_transaction_end_handler,
|
||||
NULL, NULL );
|
||||
}
|
||||
|
@ -496,10 +496,10 @@ gnc_transaction_end_handler(gpointer data_for_children,
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
g_return_val_if_fail(tree, FALSE);
|
||||
|
||||
trn = dom_tree_to_transaction(tree);
|
||||
|
||||
trn = dom_tree_to_transaction(tree, gdata->sessiondata);
|
||||
if(trn != NULL)
|
||||
{
|
||||
gdata->cb(tag, gdata->parsedata, trn);
|
||||
@ -512,14 +512,14 @@ gnc_transaction_end_handler(gpointer data_for_children,
|
||||
}
|
||||
|
||||
Transaction *
|
||||
dom_tree_to_transaction( xmlNodePtr node )
|
||||
dom_tree_to_transaction( xmlNodePtr node, GNCSession *session )
|
||||
{
|
||||
Transaction *trn;
|
||||
gboolean successful;
|
||||
|
||||
g_return_val_if_fail(node, FALSE);
|
||||
|
||||
trn = xaccMallocTransaction();
|
||||
trn = xaccMallocTransaction(session);
|
||||
g_return_val_if_fail(trn, FALSE);
|
||||
xaccTransBeginEdit(trn);
|
||||
|
||||
|
@ -942,7 +942,7 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
|
||||
ENTER (" ");
|
||||
|
||||
/* create a transaction structure */
|
||||
trans = xaccMallocTransaction();
|
||||
trans = xaccMallocTransaction(session);
|
||||
xaccTransBeginEdit (trans);
|
||||
|
||||
tmp = readString( fd, revision );
|
||||
|
@ -2759,10 +2759,14 @@ txn_restore_start_handler(GSList* sibling_data, gpointer parent_data,
|
||||
gpointer global_data, gpointer *data_for_children,
|
||||
gpointer *result, const gchar *tag, gchar **attrs)
|
||||
{
|
||||
Transaction *trans = xaccMallocTransaction();
|
||||
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
|
||||
Transaction *trans = xaccMallocTransaction(pstatus->session);
|
||||
|
||||
g_return_val_if_fail(trans, FALSE);
|
||||
|
||||
xaccTransBeginEdit(trans);
|
||||
*data_for_children = trans;
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ kvp_value* dom_tree_to_frame_kvp_value(xmlNodePtr node);
|
||||
gboolean dom_tree_to_integer(xmlNodePtr node, gint64 *daint);
|
||||
|
||||
Account* dom_tree_to_account(xmlNodePtr node, GNCSession *session);
|
||||
Transaction* dom_tree_to_transaction(xmlNodePtr node);
|
||||
Transaction* dom_tree_to_transaction(xmlNodePtr node, GNCSession *session);
|
||||
|
||||
struct dom_tree_handler
|
||||
{
|
||||
|
@ -325,9 +325,9 @@ query_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
xaccTransBeginEdit (trans);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
trans = xaccMallocTransaction();
|
||||
trans = xaccMallocTransaction(be->session);
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccTransSetGUID (trans, &trans_guid);
|
||||
}
|
||||
|
@ -530,13 +530,14 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
trans = xaccTransLookup (trans_guid);
|
||||
if (!trans)
|
||||
{
|
||||
trans = xaccMallocTransaction();
|
||||
trans = xaccMallocTransaction(be->session);
|
||||
do_set_guid=TRUE;
|
||||
engine_data_is_newer = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* save some performance, don't go to the backend if the data is recent. */
|
||||
/* save some performance, don't go to the
|
||||
backend if the data is recent. */
|
||||
if (MAX_VERSION_AGE >= be->version_check - trans->version_check)
|
||||
{
|
||||
PINFO ("fresh data, skip check");
|
||||
|
@ -87,7 +87,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
}
|
||||
else
|
||||
{
|
||||
trans = xaccMallocTransaction();
|
||||
trans = xaccMallocTransaction(be->session);
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccTransSetGUID (trans, &trans_guid);
|
||||
}
|
||||
|
@ -567,7 +567,9 @@ pack_split_info(TTSplitInfo *s_info, Account *parent_acct, Transaction *parent_t
|
||||
}
|
||||
|
||||
|
||||
void xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list)
|
||||
void
|
||||
xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
|
||||
GNCSession *session)
|
||||
{
|
||||
|
||||
Transaction *new_trans;
|
||||
@ -583,7 +585,7 @@ void xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list)
|
||||
{
|
||||
tti = t_t_list->data;
|
||||
|
||||
new_trans = xaccMallocTransaction();
|
||||
new_trans = xaccMallocTransaction(session);
|
||||
|
||||
xaccTransBeginEdit(new_trans);
|
||||
|
||||
|
@ -230,6 +230,7 @@ GDate xaccSchedXactionGetInstanceAfter( SchedXaction *sx, GDate *date );
|
||||
* the edit dialog doesn't use this mechanism. Maybe it should
|
||||
*/
|
||||
|
||||
void xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list);
|
||||
void xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
|
||||
GNCSession *session);
|
||||
|
||||
#endif /* XACC_SCHEDXACTION_H */
|
||||
|
@ -611,7 +611,7 @@ xaccSplitGetReconciledBalance (Split *s) {
|
||||
\********************************************************************/
|
||||
|
||||
static void
|
||||
xaccInitTransaction (Transaction * trans)
|
||||
xaccInitTransaction (Transaction * trans, GNCSession *session)
|
||||
{
|
||||
/* Fill in some sane defaults */
|
||||
trans->num = g_cache_insert(gnc_engine_get_string_cache(), "");
|
||||
@ -644,11 +644,11 @@ xaccInitTransaction (Transaction * trans)
|
||||
\********************************************************************/
|
||||
|
||||
Transaction *
|
||||
xaccMallocTransaction (void)
|
||||
xaccMallocTransaction (GNCSession *session)
|
||||
{
|
||||
Transaction *trans = g_new(Transaction, 1);
|
||||
|
||||
xaccInitTransaction (trans);
|
||||
xaccInitTransaction (trans, session);
|
||||
|
||||
gnc_engine_generate_event (&trans->guid, GNC_EVENT_CREATE);
|
||||
|
||||
|
@ -76,9 +76,10 @@ int xaccConfigGetForceDoubleEntry (void);
|
||||
* Once created, it is usually unsafe to merely "free" this memory;
|
||||
* the xaccTransDestroy() method should be called.
|
||||
*/
|
||||
Transaction * xaccMallocTransaction (void);
|
||||
Transaction * xaccMallocTransaction (GNCSession *session);
|
||||
|
||||
gboolean xaccTransEqual(const Transaction *ta, const Transaction *tb,
|
||||
gboolean xaccTransEqual(const Transaction *ta,
|
||||
const Transaction *tb,
|
||||
gboolean check_guids,
|
||||
gboolean check_splits);
|
||||
|
||||
|
@ -1674,7 +1674,7 @@ of having a parent transaction with which one is working...")
|
||||
'gnc:transaction-create
|
||||
'<gnc:Transaction*>
|
||||
"xaccMallocTransaction"
|
||||
'()
|
||||
'((<gnc:Session*> session>))
|
||||
"Create a Transaction structure")
|
||||
|
||||
(gw:wrap-function
|
||||
|
@ -567,7 +567,7 @@ get_random_transaction(GNCSession *session)
|
||||
{
|
||||
Transaction* ret;
|
||||
|
||||
ret = xaccMallocTransaction();
|
||||
ret = xaccMallocTransaction(session);
|
||||
|
||||
xaccTransBeginEdit(ret);
|
||||
|
||||
|
@ -226,7 +226,7 @@ gnc_account_create_transfer_balance (Account *account,
|
||||
xaccAccountBeginEdit (account);
|
||||
xaccAccountBeginEdit (transfer);
|
||||
|
||||
trans = xaccMallocTransaction ();
|
||||
trans = xaccMallocTransaction (gnc_get_current_session ());
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
|
||||
|
@ -280,7 +280,7 @@ create_each_transaction( Transaction *t, void *d )
|
||||
|
||||
gd = (GDate*)d;
|
||||
|
||||
newT = xaccMallocTransaction();
|
||||
newT = xaccMallocTransaction(gnc_get_current_session ());
|
||||
xaccTransBeginEdit( newT );
|
||||
/* the action and description/memo are in the template */
|
||||
gnc_copy_trans_onto_trans( t, newT, FALSE, FALSE );
|
||||
|
@ -196,7 +196,7 @@ sxftd_add_template_trans(SXFromTransInfo *sxfti)
|
||||
split_value = xaccSplitGetValue(sp);
|
||||
gnc_ttsplitinfo_set_memo(ttsi, xaccSplitGetMemo(sp));
|
||||
|
||||
if(gnc_numeric_positive_p(split_value)) /* FIXME:I still can't remember which one is stored positive :) */
|
||||
if(gnc_numeric_positive_p(split_value))
|
||||
{
|
||||
gnc_ttsplitinfo_set_debit_formula_numeric(ttsi, split_value);
|
||||
}
|
||||
@ -212,7 +212,8 @@ sxftd_add_template_trans(SXFromTransInfo *sxfti)
|
||||
|
||||
tt_list = g_list_append(tt_list, tti);
|
||||
|
||||
xaccSchedXactionSetTemplateTrans(sxfti->sx, tt_list);
|
||||
xaccSchedXactionSetTemplateTrans(sxfti->sx, tt_list,
|
||||
gnc_get_current_session ());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1114,7 +1114,7 @@ _create_each_transaction_helper( Transaction *t, void *d )
|
||||
createUD = (createData*)d;
|
||||
tct = createUD->tct;
|
||||
|
||||
newT = xaccMallocTransaction();
|
||||
newT = xaccMallocTransaction(gnc_get_current_session ());
|
||||
xaccTransBeginEdit( newT );
|
||||
/* the action and description/memo are in the template */
|
||||
gnc_copy_trans_onto_trans( t, newT, FALSE, FALSE );
|
||||
|
@ -1112,7 +1112,7 @@ gnc_xfer_dialog_ok_cb(GtkWidget * widget, gpointer data)
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* Create the transaction */
|
||||
trans = xaccMallocTransaction();
|
||||
trans = xaccMallocTransaction(gnc_get_current_session ());
|
||||
|
||||
xaccTransBeginEdit(trans);
|
||||
|
||||
|
@ -366,7 +366,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
trans = xaccMallocTransaction ();
|
||||
trans = xaccMallocTransaction (gnc_get_current_session ());
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
|
||||
|
@ -330,7 +330,8 @@
|
||||
(if (not (qif-xtn:mark xtn))
|
||||
(begin
|
||||
;; create and fill in the GNC transaction
|
||||
(let ((gnc-xtn (gnc:transaction-create)))
|
||||
(let ((gnc-xtn (gnc:transaction-create
|
||||
(gnc:get-current-session))))
|
||||
(gnc:transaction-begin-edit gnc-xtn)
|
||||
|
||||
;; FIXME. This is probably wrong
|
||||
|
@ -36,8 +36,8 @@
|
||||
(define (qif-io:bank-xtn-import qif-xtn qif-file gnc-acct-info commodity)
|
||||
(let* ((format-info
|
||||
(qif-io:file-bank-xtn-format qif-file))
|
||||
(gnc-xtn (gnc:transaction-create))
|
||||
(near-split-amt
|
||||
(gnc-xtn (gnc:transaction-create (gnc:get-current-session)))
|
||||
(near-split-amt
|
||||
;; the u-amount has a larger range and is more correct,
|
||||
;; but is optional
|
||||
(let ((uamt (qif-io:bank-xtn-u-amount qif-xtn)))
|
||||
|
@ -146,7 +146,7 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define (qif-io:invst-xtn-import qif-xtn qif-file gnc-acct-info commodity)
|
||||
(let ((gnc-xtn (gnc:transaction-create))
|
||||
(let ((gnc-xtn (gnc:transaction-create (gnc:get-current-session)))
|
||||
(format-info (qif-io:file-invst-xtn-format qif-file)))
|
||||
;; utility to make a new split and add it both to an
|
||||
;; account and to the transaction
|
||||
|
@ -174,7 +174,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
trans = xaccMallocTransaction ();
|
||||
trans = xaccMallocTransaction (gnc_get_current_session ());
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccTransSetCurrency (trans, gnc_default_currency ()); /* is this lame? */
|
||||
|
@ -574,7 +574,7 @@ gnc_split_register_duplicate_current (SplitRegister *reg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_trans = xaccMallocTransaction ();
|
||||
new_trans = xaccMallocTransaction (gnc_get_current_session ());
|
||||
|
||||
xaccTransBeginEdit (new_trans);
|
||||
gnc_copy_trans_onto_trans (trans, new_trans, FALSE, FALSE);
|
||||
|
Loading…
Reference in New Issue
Block a user