Work on moving entity tables into sessions.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5466 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-10-05 08:35:04 +00:00
parent 97510c5cb3
commit 97b19d1878
33 changed files with 235 additions and 137 deletions

View File

@ -927,7 +927,7 @@ gnc_account_create_opening_balance (Account *account,
xaccTransSetDateSecs (trans, date);
xaccTransSetDescription (trans, _("Opening Balance"));
split = xaccMallocSplit ();
split = xaccMallocSplit (session);
xaccTransAppendSplit (trans, split);
xaccAccountInsertSplit (account, split);
@ -937,7 +937,7 @@ gnc_account_create_opening_balance (Account *account,
balance = gnc_numeric_neg (balance);
split = xaccMallocSplit ();
split = xaccMallocSplit (session);
xaccTransAppendSplit (trans, split);
xaccAccountInsertSplit (equity_account, split);

View File

@ -733,10 +733,10 @@ gnc_copy_trans(Transaction *trans, gboolean use_cut_semantics)
\********************************************************************/
void
gnc_copy_trans_scm_onto_trans(SCM trans_scm, Transaction *trans,
gboolean do_commit)
gboolean do_commit, GNCSession *session)
{
gnc_copy_trans_scm_onto_trans_swap_accounts(trans_scm, trans, NULL, NULL,
do_commit);
do_commit, session);
}
@ -758,7 +758,8 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
Transaction *trans,
const GUID *guid_1,
const GUID *guid_2,
gboolean do_commit)
gboolean do_commit,
GNCSession *session)
{
static SCM trans_type = SCM_UNDEFINED;
SCM result;
@ -771,6 +772,8 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
if (trans == NULL)
return;
g_return_if_fail (session);
func = gh_eval_str("gnc:transaction-scm?");
if (!gh_procedure_p(func))
return;
@ -798,6 +801,7 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
commit = gh_bool2scm(do_commit);
args = gh_cons(gnc_session_to_scm (session), args);
args = gh_cons(commit, args);
args = gh_cons(SCM_EOL, args);
args = gh_cons(arg, args);
@ -813,6 +817,8 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
SCM commit;
char *guid_str;
args = gh_cons(gnc_session_to_scm (session), args);
commit = gh_bool2scm(do_commit);
args = gh_cons(commit, args);

View File

@ -68,12 +68,13 @@ gnc_numeric gnc_split_scm_get_value(SCM split_scm);
SCM gnc_copy_trans(Transaction *trans, gboolean use_cut_semantics);
void gnc_copy_trans_scm_onto_trans(SCM trans_scm, Transaction *trans,
gboolean do_commit);
gboolean do_commit, GNCSession *session);
void gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
Transaction *trans,
const GUID *guid_1,
const GUID *guid_2,
gboolean do_commit);
gboolean do_commit,
GNCSession *session);
void gnc_trans_scm_set_date(SCM trans_scm, Timespec *ts);
void gnc_trans_scm_set_num(SCM trans_scm, const char *num);

View File

@ -312,11 +312,13 @@ struct dom_tree_handler spl_dom_handlers[] =
};
Split*
dom_tree_to_split(xmlNodePtr node)
dom_tree_to_split(xmlNodePtr node, GNCSession *session)
{
Split *ret;
ret = xaccMallocSplit();
g_return_val_if_fail (session, NULL);
ret = xaccMallocSplit(session);
g_return_val_if_fail(ret, NULL);
/* this isn't going to work in a testing setup */
@ -331,43 +333,17 @@ dom_tree_to_split(xmlNodePtr node)
}
}
static gboolean
trn_splits_handler(xmlNodePtr node, gpointer trn)
{
xmlNodePtr mark;
g_return_val_if_fail(node, FALSE);
g_return_val_if_fail(node->xmlChildrenNode, FALSE);
for(mark = node->xmlChildrenNode; mark; mark = mark->next)
{
Split *spl;
if(safe_strcmp("trn:split", mark->name))
{
return FALSE;
}
spl = dom_tree_to_split(mark);
if(spl)
{
xaccTransAppendSplit((Transaction*)trn, spl);
}
else
{
return FALSE;
}
}
return TRUE;
}
/***********************************************************************/
struct trans_pdata
{
Transaction *trans;
GNCSession *session;
};
static gboolean
set_tran_string(xmlNodePtr node, Transaction *trn,
void (*func)(Transaction *trn, const char *txt))
void (*func)(Transaction *trn, const char *txt))
{
gchar *tmp;
@ -384,7 +360,7 @@ set_tran_string(xmlNodePtr node, Transaction *trn,
static gboolean
set_tran_date(xmlNodePtr node, Transaction *trn,
void (*func)(Transaction *trn, const Timespec *tm))
void (*func)(Transaction *trn, const Timespec *tm))
{
Timespec *tm;
@ -400,9 +376,12 @@ set_tran_date(xmlNodePtr node, Transaction *trn,
}
static gboolean
trn_id_handler(xmlNodePtr node, gpointer trn)
trn_id_handler(xmlNodePtr node, gpointer trans_pdata)
{
struct trans_pdata *pdata = trans_pdata;
Transaction *trn = pdata->trans;
GUID *tmp = dom_tree_to_guid(node);
g_return_val_if_fail(tmp, FALSE);
xaccTransSetGUID((Transaction*)trn, tmp);
@ -413,8 +392,10 @@ trn_id_handler(xmlNodePtr node, gpointer trn)
}
static gboolean
trn_currency_handler(xmlNodePtr node, gpointer trn)
trn_currency_handler(xmlNodePtr node, gpointer trans_pdata)
{
struct trans_pdata *pdata = trans_pdata;
Transaction *trn = pdata->trans;
gnc_commodity *ref;
ref = dom_tree_to_commodity_ref_no_engine(node);
@ -424,32 +405,46 @@ trn_currency_handler(xmlNodePtr node, gpointer trn)
}
static gboolean
trn_num_handler(xmlNodePtr node, gpointer trn)
trn_num_handler(xmlNodePtr node, gpointer trans_pdata)
{
return set_tran_string(node, (Transaction*)trn, xaccTransSetNum);
struct trans_pdata *pdata = trans_pdata;
Transaction *trn = pdata->trans;
return set_tran_string(node, trn, xaccTransSetNum);
}
static gboolean
trn_date_posted_handler(xmlNodePtr node, gpointer trn)
trn_date_posted_handler(xmlNodePtr node, gpointer trans_pdata)
{
return set_tran_date(node, (Transaction*)trn, xaccTransSetDatePostedTS);
struct trans_pdata *pdata = trans_pdata;
Transaction *trn = pdata->trans;
return set_tran_date(node, trn, xaccTransSetDatePostedTS);
}
static gboolean
trn_date_entered_handler(xmlNodePtr node, gpointer trn)
trn_date_entered_handler(xmlNodePtr node, gpointer trans_pdata)
{
return set_tran_date(node, (Transaction*)trn, xaccTransSetDateEnteredTS);
struct trans_pdata *pdata = trans_pdata;
Transaction *trn = pdata->trans;
return set_tran_date(node, trn, xaccTransSetDateEnteredTS);
}
static gboolean
trn_description_handler(xmlNodePtr node, gpointer trn)
trn_description_handler(xmlNodePtr node, gpointer trans_pdata)
{
return set_tran_string(node, (Transaction*)trn, xaccTransSetDescription);
struct trans_pdata *pdata = trans_pdata;
Transaction *trn = pdata->trans;
return set_tran_string(node, trn, xaccTransSetDescription);
}
static gboolean
trn_slots_handler(xmlNodePtr node, gpointer trn)
trn_slots_handler(xmlNodePtr node, gpointer trans_pdata)
{
struct trans_pdata *pdata = trans_pdata;
Transaction *trn = pdata->trans;
gboolean successful;
successful = dom_tree_to_kvp_frame_given(node, xaccTransGetSlots(trn));
@ -459,6 +454,38 @@ trn_slots_handler(xmlNodePtr node, gpointer trn)
return TRUE;
}
static gboolean
trn_splits_handler(xmlNodePtr node, gpointer trans_pdata)
{
struct trans_pdata *pdata = trans_pdata;
Transaction *trn = pdata->trans;
xmlNodePtr mark;
g_return_val_if_fail(node, FALSE);
g_return_val_if_fail(node->xmlChildrenNode, FALSE);
for(mark = node->xmlChildrenNode; mark; mark = mark->next)
{
Split *spl;
if(safe_strcmp("trn:split", mark->name))
{
return FALSE;
}
spl = dom_tree_to_split(mark, pdata->session);
if(spl)
{
xaccTransAppendSplit(trn, spl);
}
else
{
return FALSE;
}
}
return TRUE;
}
struct dom_tree_handler trn_dom_handlers[] =
{
@ -516,15 +543,20 @@ dom_tree_to_transaction( xmlNodePtr node, GNCSession *session )
{
Transaction *trn;
gboolean successful;
struct trans_pdata pdata;
g_return_val_if_fail(node, FALSE);
g_return_val_if_fail(node, NULL);
g_return_val_if_fail(session, NULL);
trn = xaccMallocTransaction(session);
g_return_val_if_fail(trn, FALSE);
g_return_val_if_fail(trn, NULL);
xaccTransBeginEdit(trn);
successful = dom_tree_generic_parse(node, trn_dom_handlers, trn);
pdata.trans = trn;
pdata.session = session;
successful = dom_tree_generic_parse(node, trn_dom_handlers, &pdata);
xaccTransCommitEdit(trn);
if ( !successful )
@ -536,7 +568,6 @@ dom_tree_to_transaction( xmlNodePtr node, GNCSession *session )
trn = NULL;
}
//xmlFreeNode(tree);
return trn;
}

View File

@ -27,16 +27,12 @@
#include "config.h"
#include "gnc-xml-helper.h"
#include "Account.h"
#include "gnc-commodity.h"
#include "sixtp.h"
#include "gnc-pricedb.h"
#include "FreqSpec.h"
#include "SchedXaction.h"
#include "gnc-pricedb.h"
#include "gnc-session.h"
#include "gnc-xml-helper.h"
#include "sixtp.h"
xmlNodePtr gnc_account_dom_tree_create(Account *act);
sixtp* gnc_account_sixtp_parser_create(void);
@ -48,7 +44,7 @@ xmlNodePtr gnc_transaction_dom_tree_create(Transaction *com);
sixtp* gnc_transaction_sixtp_parser_create(void);
xmlNodePtr split_to_dom_tree(const gchar *tag, Split *spl);
Split* dom_tree_to_split(xmlNodePtr node);
Split* dom_tree_to_split(xmlNodePtr node, GNCSession *session);
xmlNodePtr gnc_pricedb_dom_tree_create(GNCPriceDB *db);
sixtp* gnc_pricedb_sixtp_parser_create(void);

View File

@ -1089,9 +1089,9 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
/* The code below really wants to assume that there are a pair
* of splits in every transaction, so make it so.
*/
s = xaccMallocSplit ();
s = xaccMallocSplit (session);
xaccTransAppendSplit (trans, s);
s = xaccMallocSplit ();
s = xaccMallocSplit (session);
xaccTransAppendSplit (trans, s);
s = xaccTransGetSplit (trans, 0);
@ -1275,7 +1275,7 @@ readSplit ( GNCSession *session, int fd, int token )
ENTER (" ");
/* create a split structure */
split = xaccMallocSplit();
split = xaccMallocSplit(session);
tmp = readString( fd, token );
if( NULL == tmp )

View File

@ -3064,7 +3064,8 @@ txn_restore_split_start_handler(GSList* sibling_data, gpointer parent_data,
gpointer *data_for_children, gpointer *result,
const gchar *tag, gchar **attrs)
{
Split *s = xaccMallocSplit();
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
Split *s = xaccMallocSplit(pstatus->session);
g_return_val_if_fail(s, FALSE);
*data_for_children = s;
return(TRUE);

View File

@ -407,7 +407,7 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
s = xaccSplitLookup (&guid);
if (!s)
{
s = xaccMallocSplit();
s = xaccMallocSplit(be->session);
xaccSplitSetGUID(s, &guid);
}

View File

@ -141,7 +141,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
s = xaccSplitLookup (&guid);
if (!s)
{
s = xaccMallocSplit();
s = xaccMallocSplit(be->session);
xaccSplitSetGUID(s, &guid);
}

View File

@ -53,7 +53,8 @@
/** STRUCTS *********************************************************/
struct _account {
struct account_s
{
/* public data, describes account */
GUID guid; /* globally unique account id */

View File

@ -24,11 +24,15 @@
#ifndef GNC_ID_P_H
#define GNC_ID_P_H 1
#include <glib.h>
#include "GNCId.h"
/* This file defines an engine-only API for using gnucash entity
* identifiers. */
typedef GHashTable GNCEntityTable;
/* Generate a new id. This function is guaranteed to return an id that
* is unique within the scope of all GnuCash entities being managed by
* the current invocation of GnuCash. GnuCash routines should always

View File

@ -46,7 +46,7 @@
/** STRUCTS *********************************************************/
struct _account_group
struct account_group_s
{
/* The flags: */
unsigned int saved : 1;

View File

@ -509,14 +509,15 @@ xaccSchedXactionIsDirty(SchedXaction *sx)
static Split *
pack_split_info(TTSplitInfo *s_info, Account *parent_acct, Transaction *parent_trans)
pack_split_info (TTSplitInfo *s_info, Account *parent_acct,
Transaction *parent_trans, GNCSession *session)
{
Split *split;
kvp_frame *split_frame, *sx_frame;
kvp_value *tmp_value;
const GUID *acc_guid;
split = xaccMallocSplit();
split = xaccMallocSplit(session);
xaccSplitSetMemo(split,
gnc_ttsplitinfo_get_memo(s_info));
@ -571,14 +572,15 @@ void
xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
GNCSession *session)
{
Transaction *new_trans;
TTInfo *tti;
TTSplitInfo *s_info;
Split *new_split;
/* delete any old transactions, if there are any */
GList *split_list;
g_return_if_fail (session);
/* delete any old transactions, if there are any */
delete_template_trans( sx );
for(;t_t_list != NULL; t_t_list = t_t_list->next)
@ -600,15 +602,10 @@ xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
split_list = split_list->next)
{
s_info = split_list->data;
new_split = pack_split_info(s_info, sx->template_acct, new_trans);
new_split = pack_split_info(s_info, sx->template_acct,
new_trans, session);
xaccTransAppendSplit(new_trans, new_split);
}
xaccTransCommitEdit(new_trans);
}
return;
}

View File

@ -354,7 +354,7 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
/* put split into account before setting split value */
if (!balance_split)
{
balance_split = xaccMallocSplit ();
balance_split = xaccMallocSplit (session);
xaccAccountBeginEdit (account);
xaccAccountInsertSplit (account, balance_split);

View File

@ -31,13 +31,11 @@
#include <time.h>
#include <unistd.h>
#include "Account.h"
#include "AccountP.h"
#include "BackendP.h"
#include "GNCIdP.h"
#include "Group.h"
#include "Scrub.h"
#include "Transaction.h"
#include "TransactionP.h"
#include "TransLog.h"
#include "date.h"
@ -45,6 +43,7 @@
#include "gnc-engine-util.h"
#include "gnc-engine.h"
#include "gnc-event-p.h"
#include "gnc-session-p.h"
#include "messages.h"
@ -93,7 +92,7 @@ check_open (Transaction *trans)
\********************************************************************/
static void
xaccInitSplit(Split * split)
xaccInitSplit(Split * split, GNCEntityTable *entity_table)
{
/* fill in some sane defaults */
xaccSplitSetAccount(split, NULL);
@ -122,14 +121,28 @@ xaccInitSplit(Split * split)
/********************************************************************\
\********************************************************************/
Split *
xaccMallocSplit(void)
static Split *
xaccMallocSplitEntityTable (GNCEntityTable *entity_table)
{
Split *split = g_new(Split, 1);
xaccInitSplit (split);
Split *split;
/* FIXME: uncomment this when done with moving entity
* tables into sessions. */
/* g_return_val_if_fail (entity_table, NULL); */
split = g_new (Split, 1);
xaccInitSplit (split, entity_table);
return split;
}
Split *
xaccMallocSplit(GNCSession *session)
{
g_return_val_if_fail (session, NULL);
return xaccMallocSplitEntityTable (gnc_session_get_entity_table (session));
}
/********************************************************************\
\********************************************************************/
/* This routine is not exposed externally, since it does weird things,
@ -638,6 +651,7 @@ xaccInitTransaction (Transaction * trans, GNCSession *session)
xaccGUIDNew(&trans->guid);
xaccStoreEntity(trans, &trans->guid, GNC_ID_TRANS);
trans->entity_table = NULL;
}
/********************************************************************\
@ -1312,7 +1326,7 @@ xaccTransCommitEdit (Transaction *trans)
trans->date_entered.tv_sec = tv.tv_sec;
trans->date_entered.tv_nsec = 1000 * tv.tv_usec;
}
/* Alternately the transaction may have only one split in
* it, in which case that's OK if and only if the split has no
* value (i.e. is only recording a price). Otherwise, a single
@ -1324,7 +1338,7 @@ xaccTransCommitEdit (Transaction *trans)
if ((1 == force_double_entry) &&
(NULL == g_list_nth(trans->splits, 1)) &&
(!gnc_numeric_zero_p(split->amount))) {
Split * s = xaccMallocSplit();
Split * s = xaccMallocSplitEntityTable(trans->entity_table);
xaccTransAppendSplit (trans, s);
xaccAccountInsertSplit (xaccSplitGetAccount(s), s);
xaccSplitSetMemo (s, split->memo);

View File

@ -43,10 +43,10 @@
/** STRUCTS *********************************************************/
typedef struct _account Account;
typedef struct _account_group AccountGroup;
typedef struct _split Split;
typedef struct _transaction Transaction;
typedef struct account_s Account;
typedef struct account_group_s AccountGroup;
typedef struct split_s Split;
typedef struct transaction_s Transaction;
/** PROTOTYPES ******************************************************/
@ -243,7 +243,7 @@ void xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr);
gnc_numeric xaccTransGetImbalance (Transaction * trans);
/* ------------- splits --------------- */
Split * xaccMallocSplit (void);
Split * xaccMallocSplit (GNCSession *session);
gboolean xaccSplitEqual(const Split *sa, const Split *sb,
gboolean check_guids,

View File

@ -52,7 +52,7 @@
#include "kvp_frame.h"
#include "gnc-numeric.h"
#include "Transaction.h" /* for typedefs */
#include "GNCId.h"
#include "GNCIdP.h"
/** STRUCTS *********************************************************/
@ -74,7 +74,7 @@
*/
struct _split
struct split_s
{
GUID guid; /* globally unique id */
@ -128,13 +128,16 @@ struct _split
};
struct _transaction
struct transaction_s
{
/* guid is a globally unique identifier which can be used to
* reference the transaction.
*/
GUID guid;
/* entity_table is the table where the transaction is stored by guid */
GNCEntityTable *entity_table;
Timespec date_entered; /* date register entry was made */
Timespec date_posted; /* date transaction was posted at bank */

View File

@ -1554,6 +1554,29 @@ gnc_book_to_scm (GNCBook *book)
return gw_wcp_assimilate_ptr ((void *) book, book_type);
}
/********************************************************************
* gnc_session_to_scm
********************************************************************/
SCM
gnc_session_to_scm (GNCSession *session)
{
static SCM session_type = SCM_UNDEFINED;
if (!session)
return SCM_BOOL_F;
if (session_type == SCM_UNDEFINED)
{
session_type = gh_eval_str ("<gnc:Session*>");
/* don't really need this - types are bound globally anyway. */
if (session_type != SCM_UNDEFINED)
scm_protect_object (session_type);
}
return gw_wcp_assimilate_ptr ((void *) session, session_type);
}
/********************************************************************
* gnc_glist_commodity_ptr_to_scm
********************************************************************/

View File

@ -81,6 +81,7 @@ int gnc_numeric_p(SCM arg);
gnc_commodity * gnc_scm_to_commodity(SCM scm);
SCM gnc_commodity_to_scm (const gnc_commodity *commodity);
SCM gnc_book_to_scm (GNCBook *book);
SCM gnc_session_to_scm (GNCSession *session);
/* The GList is freed */
SCM gnc_glist_account_ptr_to_scm(GList *account_list);

View File

@ -240,7 +240,7 @@
;; guid-mapping must be an alist, mapping guids to guids. This list is
;; used to use alternate account guids when creating splits.
(define (gnc:transaction-scm-onto-transaction trans-scm trans guid-mapping
commit?)
commit? session)
(if (not trans)
#f
(begin
@ -272,7 +272,7 @@
;; order as in the original transaction. This is important.
(let loop ((split-scms (gnc:transaction-scm-get-split-scms trans-scm)))
(if (pair? split-scms)
(let* ((new-split (gnc:split-create))
(let* ((new-split (gnc:split-create session))
(split-scm (car split-scms))
(old-guid (gnc:split-scm-get-account-guid split-scm))
(new-guid (assoc-ref guid-mapping old-guid)))

View File

@ -29,16 +29,22 @@
#define GNC_SESSION_P_H
#include "BackendP.h"
#include "GNCIdP.h"
#include "TransLog.h"
#include "gnc-book.h"
#include "gnc-engine-util.h"
#include "gnc-engine.h"
#include "gnc-session.h"
struct gnc_session_struct
{
/* The book is the cache for the underlying gnucash dataset. */
GNCBook *book;
/* The entity table associates the GUIDs of all the objects
* created in the session with their respective objects
* (pointer addresses) */
GNCEntityTable *entity_table;
/* the requested book id, in the form or a URI, such as
* file:/some/where, or sql:server.host.com:555
*/
@ -66,7 +72,9 @@ struct gnc_session_struct
void gnc_session_set_book (GNCSession *session, GNCBook *book);
Backend * gnc_session_get_backend (GNCSession *session);
GNCEntityTable *gnc_session_get_entity_table (GNCSession *session);
Backend * gnc_session_get_backend (GNCSession *session);
/*
* used by backends to mark the notsaved as FALSE just after

View File

@ -120,7 +120,7 @@ gnc_session_init (GNCSession *session)
if (!session) return;
session->book = gnc_book_new ();
session->entity_table = NULL;
session->book_id = NULL;
session->fullpath = NULL;
session->logpath = NULL;
@ -158,6 +158,13 @@ gnc_session_set_book (GNCSession *session, GNCBook *book)
session->book = book;
}
GNCEntityTable *
gnc_session_get_entity_table (GNCSession *session)
{
if (!session) return NULL;
return session->entity_table;
}
Backend *
gnc_session_get_backend (GNCSession *session)
{

View File

@ -1682,7 +1682,7 @@ of having a parent transaction with which one is working...")
'gnc:split-create
'<gnc:Split*>
"xaccMallocSplit"
'()
'((<gnc:Session*> session>>))
"Create a Split structure")
(gw:wrap-function

View File

@ -502,8 +502,8 @@ get_random_split(GNCSession *session, gnc_numeric num)
{
Split *ret;
gnc_numeric oneVal;
ret = xaccMallocSplit();
ret = xaccMallocSplit(session);
set_split_random_string(ret, xaccSplitSetMemo);
set_split_random_string(ret, xaccSplitSetAction);

View File

@ -234,7 +234,7 @@ gnc_account_create_transfer_balance (Account *account,
xaccTransSetDateSecs (trans, date);
xaccTransSetDescription (trans, _("Opening Balance"));
split = xaccMallocSplit ();
split = xaccMallocSplit (gnc_get_current_session ());
xaccTransAppendSplit (trans, split);
xaccAccountInsertSplit (account, split);
@ -244,7 +244,7 @@ gnc_account_create_transfer_balance (Account *account,
balance = gnc_numeric_neg (balance);
split = xaccMallocSplit ();
split = xaccMallocSplit (gnc_get_current_session ());
xaccTransAppendSplit (trans, split);
xaccAccountInsertSplit (transfer, split);

View File

@ -1126,11 +1126,11 @@ gnc_xfer_dialog_ok_cb(GtkWidget * widget, gpointer data)
xaccTransSetDescription(trans, string);
/* create from split */
from_split = xaccMallocSplit();
from_split = xaccMallocSplit(gnc_get_current_session ());
xaccTransAppendSplit(trans, from_split);
/* create to split */
to_split = xaccMallocSplit();
to_split = xaccMallocSplit(gnc_get_current_session ());
xaccTransAppendSplit(trans, to_split);
xaccAccountBeginEdit(from_account);

View File

@ -382,7 +382,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
xaccTransSetDescription (trans, description);
}
split = xaccMallocSplit ();
split = xaccMallocSplit (gnc_get_current_session ());
xaccAccountBeginEdit (account);
account_commits = g_list_prepend (NULL, account);
@ -441,7 +441,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
account = gnc_account_tree_get_current_account
(GNC_ACCOUNT_TREE (info->asset_tree));
split = xaccMallocSplit ();
split = xaccMallocSplit (gnc_get_current_session ());
xaccAccountBeginEdit (account);
account_commits = g_list_prepend (account_commits, account);
@ -460,7 +460,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
account = gnc_account_tree_get_current_account
(GNC_ACCOUNT_TREE (info->income_tree));
split = xaccMallocSplit ();
split = xaccMallocSplit (gnc_get_current_session ());
xaccAccountBeginEdit (account);
account_commits = g_list_prepend (account_commits, account);

View File

@ -364,7 +364,7 @@
gnc-acct-hash
qif-acct-map qif-cat-map qif-memo-map)
(let ((splits (qif-xtn:splits qif-xtn))
(gnc-near-split (gnc:split-create))
(gnc-near-split (gnc:split-create (gnc:get-current-session)))
(near-split-total (gnc:numeric-zero))
(near-acct-info #f)
(near-acct-name #f)
@ -413,7 +413,8 @@
(for-each
(lambda (qif-split)
(if (not (qif-split:mark qif-split))
(let ((gnc-far-split (gnc:split-create))
(let ((gnc-far-split (gnc:split-create
(gnc:get-current-session)))
(far-acct-info #f)
(far-acct-name #f)
(far-acct-type #f)
@ -501,7 +502,7 @@
(commission-amt (qif-xtn:commission qif-xtn))
(commission-split #f)
(defer-share-price #f)
(gnc-far-split (gnc:split-create)))
(gnc-far-split (gnc:split-create (gnc:get-current-session))))
(if (not num-shares) (set! num-shares (gnc:numeric-zero)))
(if (not share-price) (set! share-price (gnc:numeric-zero)))
@ -616,10 +617,11 @@
(if (and commission-amt commission-acct)
(begin
(set! commission-split (gnc:split-create))
(set! commission-split (gnc:split-create
(gnc:get-current-session)))
(gnc:split-set-value commission-split commission-amt)
(gnc:split-set-amount commission-split commission-amt)))
(if (and qif-near-acct qif-far-acct)
(begin
(gnc:transaction-append-split gnc-xtn gnc-near-split)

View File

@ -55,7 +55,7 @@
(acct-type (cdr acct-info))
(acct (qif-io:acct-table-lookup
gnc-acct-info acct-name acct-type))
(split (gnc:split-create)))
(split (gnc:split-create (gnc:get-current-session))))
;; make the account if necessary
(if (not acct)
(begin

View File

@ -155,7 +155,7 @@
(acct-type (cdr acct-info))
(acct (qif-io:acct-table-lookup
gnc-acct-info acct-name acct-type))
(split (gnc:split-create)))
(split (gnc:split-create (gnc:get-current-session))))
;; make the account if necessary
(if (not acct)
(begin

View File

@ -179,7 +179,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
xaccTransBeginEdit (trans);
xaccTransSetCurrency (trans, gnc_default_currency ()); /* is this lame? */
xaccTransSetDateSecs (trans, info->last_date_entered);
blank_split = xaccMallocSplit ();
blank_split = xaccMallocSplit (gnc_get_current_session ());
xaccTransAppendSplit (trans, blank_split);
xaccTransCommitEdit (trans);

View File

@ -204,7 +204,7 @@ gnc_split_register_save_cells (gpointer save_data,
other_split = xaccTransGetSplit (trans, 1);
if (!other_split)
{
other_split = xaccMallocSplit ();
other_split = xaccMallocSplit (gnc_get_current_session ());
xaccTransAppendSplit (trans, other_split);
}
}

View File

@ -200,7 +200,8 @@ gnc_copy_trans_onto_trans(Transaction *from, Transaction *to,
if (trans_scm == SCM_UNDEFINED)
return;
gnc_copy_trans_scm_onto_trans(trans_scm, to, do_commit);
gnc_copy_trans_scm_onto_trans(trans_scm, to, do_commit,
gnc_get_current_session ());
}
static int
@ -522,7 +523,7 @@ gnc_split_register_duplicate_current (SplitRegister *reg)
/* We are on a split in an expanded transaction.
* Just copy the split and add it to the transaction. */
new_split = xaccMallocSplit ();
new_split = xaccMallocSplit (gnc_get_current_session ());
xaccTransBeginEdit (trans);
xaccTransAppendSplit (trans, new_split);
@ -802,7 +803,7 @@ gnc_split_register_paste_current (SplitRegister *reg)
xaccTransBeginEdit(trans);
if (split == NULL)
{ /* We are on a null split in an expanded transaction. */
split = xaccMallocSplit();
split = xaccMallocSplit(gnc_get_current_session ());
xaccTransAppendSplit(trans, split);
}
@ -851,10 +852,12 @@ gnc_split_register_paste_current (SplitRegister *reg)
new_guid = &info->default_account;
gnc_copy_trans_scm_onto_trans_swap_accounts(copied_item, trans,
&copied_leader_guid,
new_guid, TRUE);
new_guid, TRUE,
gnc_get_current_session ());
}
else
gnc_copy_trans_scm_onto_trans(copied_item, trans, TRUE);
gnc_copy_trans_scm_onto_trans(copied_item, trans, TRUE,
gnc_get_current_session ());
num_splits = xaccTransCountSplits(trans);
if (split_index >= num_splits)
@ -1219,7 +1222,7 @@ gnc_split_register_save_to_scm (SplitRegister *reg,
{
Split *temp_split;
temp_split = xaccMallocSplit ();
temp_split = xaccMallocSplit (gnc_get_current_session ());
other_split_scm = gnc_copy_split (temp_split, use_cut_semantics);
xaccSplitDestroy (temp_split);
@ -1389,7 +1392,7 @@ gnc_split_register_save (SplitRegister *reg, gboolean do_commit)
* the split to the pre-existing transaction. */
Split *trans_split;
split = xaccMallocSplit ();
split = xaccMallocSplit (gnc_get_current_session ());
xaccTransAppendSplit (trans, split);
gnc_table_set_virt_cell_data (reg->table,