Work on moving entity tables to sessions.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5463 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-10-04 00:36:28 +00:00
parent 891ac0e2b6
commit 2813e46549
34 changed files with 188 additions and 129 deletions

View File

@ -802,7 +802,8 @@ equity_base_name (GNCEquityType equity_type)
Account *
gnc_find_or_create_equity_account (AccountGroup *group,
GNCEquityType equity_type,
gnc_commodity *currency)
gnc_commodity *currency,
GNCSession *session)
{
Account *parent;
Account *account;
@ -868,7 +869,7 @@ gnc_find_or_create_equity_account (AccountGroup *group,
if (parent && xaccAccountGetType (parent) != EQUITY)
parent == NULL;
account = xaccMallocAccount ();
account = xaccMallocAccount (session);
xaccAccountBeginEdit (account);
@ -895,7 +896,8 @@ gnc_find_or_create_equity_account (AccountGroup *group,
gboolean
gnc_account_create_opening_balance (Account *account,
gnc_numeric balance,
time_t date)
time_t date,
GNCSession *session)
{
Account *equity_account;
Transaction *trans;
@ -909,7 +911,8 @@ gnc_account_create_opening_balance (Account *account,
equity_account =
gnc_find_or_create_equity_account (xaccAccountGetRoot (account),
EQUITY_OPENING_BALANCE,
xaccAccountGetCommodity (account));
xaccAccountGetCommodity (account),
session);
if (!equity_account)
return FALSE;

View File

@ -80,8 +80,11 @@ gnc_numeric gnc_ui_convert_balance_to_currency(gnc_numeric balance,
gnc_numeric gnc_ui_account_get_balance (Account *account,
gboolean include_children);
gnc_numeric gnc_ui_account_get_reconciled_balance(Account *account, gboolean include_children);
gnc_numeric gnc_ui_account_get_balance_as_of_date (Account *account, time_t date, gboolean include_children);
gnc_numeric gnc_ui_account_get_reconciled_balance(Account *account,
gboolean include_children);
gnc_numeric gnc_ui_account_get_balance_as_of_date (Account *account,
time_t date,
gboolean include_children);
const char * gnc_get_reconcile_str (char reconciled_flag);
@ -94,10 +97,12 @@ typedef enum
Account * gnc_find_or_create_equity_account (AccountGroup *group,
GNCEquityType equity_type,
gnc_commodity *currency);
gnc_commodity *currency,
GNCSession *session);
gboolean gnc_account_create_opening_balance (Account *account,
gnc_numeric balance,
time_t date);
time_t date,
GNCSession *session);
char * gnc_account_get_full_name (Account *account);

View File

@ -102,6 +102,14 @@
'()
"Get the current top-level book.")
(gw:wrap-function
mod
'gnc:get-current-session
'<gnc:Session*>
"gnc_get_current_session"
'()
"Get the current session.")
(gw:wrap-function
mod
'gnc:exp-parser-init

View File

@ -377,7 +377,7 @@ dom_tree_to_account (xmlNodePtr node, GNCSession * session)
Account *accToRet;
gboolean successful;
accToRet = xaccMallocAccount();
accToRet = xaccMallocAccount(session);
xaccAccountBeginEdit(accToRet);
act_pdata.account = accToRet;

View File

@ -424,7 +424,7 @@ gnc_schedXaction_end_handler(gpointer data_for_children,
g_return_val_if_fail( tree, FALSE );
sx = xaccSchedXactionMalloc( NULL );
sx = xaccSchedXactionMalloc( gdata->sessiondata );
/* FIXME: this should be removed somewhere near 1.8 release time. */
{

View File

@ -22,8 +22,8 @@
* *
\********************************************************************/
#ifndef _GNC_XML_HELPER_H_
#define _GNC_XML_HELPER_H_
#ifndef GNC_XML_HELPER_H
#define GNC_XML_HELPER_H
#include "config.h"

View File

@ -250,14 +250,15 @@ cvt_potential_prices_to_pricedb_and_cleanup(GNCPriceDB **prices,
}
/** PROTOTYPES ******************************************************/
static Account *locateAccount (int acc_id);
static Account *locateAccount (int acc_id, GNCSession *session);
static AccountGroup *readGroup( GNCSession *, int fd, Account *, int token );
static Account *readAccount( GNCSession *session, int fd,
AccountGroup *, int token );
static gboolean readAccInfo( int fd, Account *, int token );
static Transaction *readTransaction( int fd, Account *, int token );
static Split *readSplit( int fd, int token );
static Transaction *readTransaction( GNCSession *session,
int fd, Account *, int token );
static Split *readSplit( GNCSession *session, int fd, int token );
static char *readString( int fd, int token );
static time_t readDMYDate( int fd, int token );
static int readTSDate( int fd, Timespec *, int token );
@ -487,7 +488,7 @@ gnc_load_financials_from_fd(GNCSession *session, int fd)
error_code = ERR_FILEIO_FILE_BAD_READ;
/* create a lost account, put the missing accounts there */
acc = xaccMallocAccount();
acc = xaccMallocAccount(session);
xaccAccountBeginEdit (acc);
xaccAccountSetName (acc, _("Lost Accounts"));
acc -> children = holder;
@ -646,11 +647,11 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
err = read( fd, &accID, sizeof(int) );
if( err != sizeof(int) ) { return NULL; }
XACC_FLIP_INT (accID);
acc = locateAccount (accID);
acc = locateAccount (accID, session);
/* locateAccountAlways should always accounts that are open for
editing in this situation */
} else {
acc = xaccMallocAccount();
acc = xaccMallocAccount(session);
xaccGroupInsertAccount (holder, acc);
xaccAccountBeginEdit (acc);
}
@ -771,7 +772,7 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
/* read the transactions */
for( i=0; i<numTrans; i++ ) {
Transaction *trans;
trans = readTransaction( fd, acc, token );
trans = readTransaction(session, fd, acc, token );
if(trans == NULL ) {
PERR ("Short Transaction Read: \n"
"\texpected %d got %d transactions \n", numTrans, i);
@ -823,8 +824,8 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
*/
static Account *
locateAccount (int acc_id) {
locateAccount (int acc_id, GNCSession *session)
{
Account * acc;
/* negative account ids denote no account */
if (0 > acc_id) return NULL;
@ -841,7 +842,7 @@ locateAccount (int acc_id) {
/* if neither, then it does not yet exist. Create it.
* Put it in the drunk tank. */
acc = xaccMallocAccount ();
acc = xaccMallocAccount (session);
xaccAccountBeginEdit(acc);
g_hash_table_insert(ids_to_unfinished_accounts,
(gpointer) acc_id,
@ -925,7 +926,7 @@ xaccTransSetAction (Transaction *trans, const char *action)
\********************************************************************/
static Transaction *
readTransaction( int fd, Account *acc, int revision)
readTransaction(GNCSession *session, int fd, Account *acc, int revision)
{
int err=0;
int acc_id;
@ -1180,7 +1181,7 @@ readTransaction( int fd, Account *acc, int revision)
}
XACC_FLIP_INT (acc_id);
DEBUG ("credit %d\n", acc_id);
peer_acc = locateAccount (acc_id);
peer_acc = locateAccount (acc_id, session);
/* insert the split part of the transaction into
* the credited account */
@ -1200,7 +1201,7 @@ readTransaction( int fd, Account *acc, int revision)
}
XACC_FLIP_INT (acc_id);
DEBUG ("debit %d\n", acc_id);
peer_acc = locateAccount (acc_id);
peer_acc = locateAccount (acc_id, session);
if (peer_acc) {
Split *s0 = xaccTransGetSplit (trans, 0);
Split *s1 = xaccTransGetSplit (trans, 1);
@ -1222,7 +1223,7 @@ readTransaction( int fd, Account *acc, int revision)
/* Version 5 files included a split that immediately
* followed the transaction, before the destination splits.
* Later versions don't have this. */
Split *split = readSplit (fd, revision);
Split *split = readSplit (session, fd, revision);
xaccTransAppendSplit(trans, split);
}
@ -1236,7 +1237,7 @@ readTransaction( int fd, Account *acc, int revision)
}
XACC_FLIP_INT (numSplits);
for (i = 0; i < numSplits; i++) {
Split *split = readSplit(fd, revision);
Split *split = readSplit(session, fd, revision);
xaccTransAppendSplit(trans, split);
if(!notes) {
@ -1261,7 +1262,7 @@ readTransaction( int fd, Account *acc, int revision)
\********************************************************************/
static Split *
readSplit ( int fd, int token )
readSplit ( GNCSession *session, int fd, int token )
{
Account *peer_acc;
Split *split;
@ -1393,7 +1394,7 @@ readSplit ( int fd, int token )
}
XACC_FLIP_INT (acc_id);
DEBUG ("account id %d", acc_id);
peer_acc = locateAccount (acc_id);
peer_acc = locateAccount (acc_id, session);
xaccAccountInsertSplit (peer_acc, split);
mark_potential_quote(split, share_price, num_shares);

View File

@ -1326,7 +1326,8 @@ account_restore_start_handler(GSList* sibling_data,
const gchar *tag,
gchar **attrs)
{
Account *acc = xaccMallocAccount();
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
Account *acc = xaccMallocAccount(pstatus->session);
g_return_val_if_fail(acc, FALSE);
xaccAccountBeginEdit(acc);

View File

@ -21,8 +21,8 @@
* *
********************************************************************/
#ifndef _SIXTP_DOM_GENERATORS_H_
#define _SIXTP_DOM_GENERATORS_H_
#ifndef SIXTP_DOM_GENERATORS_H
#define SIXTP_DOM_GENERATORS_H
#include "config.h"

View File

@ -22,8 +22,8 @@
* *
\********************************************************************/
#ifndef _SIXTP_PARSERS_H_
#define _SIXTP_PARSERS_H_
#ifndef SIXTP_PARSERS_H
#define SIXTP_PARSERS_H
#include "sixtp.h"

View File

@ -21,8 +21,8 @@
* *
********************************************************************/
#ifndef _SIXTP_STACK_H_
#define _SIXTP_STACK_H_
#ifndef SIXTP_STACK_H
#define SIXTP_STACK_H
#include <glib.h>

View File

@ -21,8 +21,8 @@
* *
********************************************************************/
#ifndef _SIXTP_UTILS_H_
#define _SIXTP_UTILS_H_
#ifndef SIXTP_UTILS_H
#define SIXTP_UTILS_H
#include "date.h"

View File

@ -21,8 +21,8 @@
* *
********************************************************************/
#ifndef _SIXTP_H_
#define _SIXTP_H_
#ifndef SIXTP_H
#define SIXTP_H
#include <glib.h>
#include <stdio.h>

View File

@ -250,7 +250,7 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
acc = xaccAccountLookup (&guid);
if (!acc)
{
acc = xaccMallocAccount();
acc = xaccMallocAccount(be->session);
xaccAccountBeginEdit(acc);
xaccAccountSetGUID(acc, &guid);
}
@ -286,7 +286,7 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
parent = xaccAccountLookup (&guid);
if (!parent)
{
parent = xaccMallocAccount();
parent = xaccMallocAccount(be->session);
xaccAccountBeginEdit(parent);
xaccAccountSetGUID(parent, &guid);
}

View File

@ -70,7 +70,7 @@ mark_account (Account *account)
\********************************************************************/
static void
xaccInitAccount (Account * acc)
xaccInitAccount (Account * acc, GNCSession *session)
{
acc->parent = NULL;
acc->children = NULL;
@ -114,11 +114,15 @@ xaccInitAccount (Account * acc)
\********************************************************************/
Account *
xaccMallocAccount (void)
xaccMallocAccount (GNCSession *session)
{
Account *acc = g_new (Account, 1);
Account *acc;
xaccInitAccount (acc);
g_return_val_if_fail (session, NULL);
acc = g_new (Account, 1);
xaccInitAccount (acc, session);
gnc_engine_generate_event (&acc->guid, GNC_EVENT_CREATE);
@ -126,11 +130,13 @@ xaccMallocAccount (void)
}
Account *
xaccCloneAccountSimple(const Account *from)
xaccCloneAccountSimple(const Account *from, GNCSession *session)
{
Account *ret;
ret = xaccMallocAccount();
ret = xaccMallocAccount (session);
g_return_val_if_fail (ret, NULL);
ret->type = from->type;

View File

@ -127,8 +127,8 @@ gboolean xaccAccountEqual(Account *a, Account* b, gboolean check_guids);
* account. The account should have been opened for editing
* (by calling xaccAccountBeginEdit()) before calling this routine.
*/
Account * xaccMallocAccount (void);
Account * xaccCloneAccountSimple(const Account *from);
Account * xaccMallocAccount (GNCSession *session);
Account * xaccCloneAccountSimple(const Account *from, GNCSession *session);
void xaccAccountBeginEdit (Account *account);
void xaccAccountCommitEdit (Account *account);
void xaccAccountDestroy (Account *account);

View File

@ -26,20 +26,17 @@
#include <glib.h>
#include <string.h>
#include "SchedXaction.h"
#include "FreqSpec.h"
#include "GNCIdP.h"
#include "Transaction.h"
#include "SX-ttinfo.h"
#include "SchedXaction.h"
#include "TransactionP.h"
#include "date.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
#include "messages.h"
#include "Account.h"
#include "Group.h"
#include "gnc-session.h"
#include "guid.h"
#include "gnc-book.h"
#include "SX-ttinfo.h"
#include "messages.h"
static short module = MOD_SX;
@ -50,12 +47,16 @@ void sxprivtransactionListMapDelete( gpointer data, gpointer user_data );
static void
xaccSchedXactionInit( SchedXaction *sx, GNCBook *book)
xaccSchedXactionInit( SchedXaction *sx, GNCSession *session)
{
GNCBook *book;
AccountGroup *ag;
char *name;
sx->freq = xaccFreqSpecMalloc();
book = gnc_session_get_book (session);
xaccGUIDNew( &sx->guid );
xaccStoreEntity( sx, &sx->guid, GNC_ID_SCHEDXACTION );
g_date_clear( &sx->last_date, 1 );
@ -71,12 +72,13 @@ xaccSchedXactionInit( SchedXaction *sx, GNCBook *book)
sx->dirty = TRUE;
/* create a new template account for our splits */
sx->template_acct = xaccMallocAccount();
sx->template_acct = xaccMallocAccount(session);
name = guid_to_string( &sx->guid );
xaccAccountSetName( sx->template_acct, name );
xaccAccountSetCommodity( sx->template_acct,
gnc_commodity_new( "template", "template",
"template", "template", 1 ) );
xaccAccountSetCommodity
(sx->template_acct,
gnc_commodity_new( "template", "template",
"template", "template", 1 ) );
g_free( name );
xaccAccountSetType( sx->template_acct, BANK );
ag = gnc_book_get_template_group( book );
@ -84,12 +86,16 @@ xaccSchedXactionInit( SchedXaction *sx, GNCBook *book)
}
SchedXaction*
xaccSchedXactionMalloc( GNCBook *book )
xaccSchedXactionMalloc(GNCSession *session)
{
SchedXaction *sx;
g_return_val_if_fail (session, NULL);
sx = g_new0( SchedXaction, 1 );
xaccSchedXactionInit( sx, book );
xaccSchedXactionInit( sx, session );
gnc_engine_generate_event( &sx->guid, GNC_EVENT_CREATE );
return sx;
}

View File

@ -103,7 +103,7 @@ typedef struct gncp_SchedXaction {
/**
* Creates and initializes a scheduled transaction.
**/
SchedXaction *xaccSchedXactionMalloc( GNCBook *book);
SchedXaction *xaccSchedXactionMalloc(GNCSession *session);
/*
* returns true if the scheduled transaction is dirty and needs to

View File

@ -51,16 +51,18 @@
static short module = MOD_SCRUB;
static Account * GetOrMakeAccount (AccountGroup *root, Transaction *trans,
const char *name_root);
const char *name_root, GNCSession *session);
/* ================================================================ */
void
xaccGroupScrubOrphans (AccountGroup *grp)
xaccGroupScrubOrphans (AccountGroup *grp, GNCSession *session)
{
GList *list;
GList *node;
g_return_if_fail (session);
if (!grp)
return;
@ -70,26 +72,30 @@ xaccGroupScrubOrphans (AccountGroup *grp)
{
Account *account = node->data;
xaccAccountTreeScrubOrphans (account);
xaccAccountTreeScrubOrphans (account, session);
}
}
void
xaccAccountTreeScrubOrphans (Account *acc)
xaccAccountTreeScrubOrphans (Account *acc, GNCSession *session)
{
g_return_if_fail (session);
if (!acc)
return;
xaccGroupScrubOrphans (xaccAccountGetChildren(acc));
xaccAccountScrubOrphans (acc);
xaccGroupScrubOrphans (xaccAccountGetChildren(acc), session);
xaccAccountScrubOrphans (acc, session);
}
void
xaccAccountScrubOrphans (Account *acc)
xaccAccountScrubOrphans (Account *acc, GNCSession *session)
{
GList *node;
const char *str;
g_return_if_fail (session);
if (!acc)
return;
@ -102,15 +108,19 @@ xaccAccountScrubOrphans (Account *acc)
Split *split = node->data;
xaccTransScrubOrphans (xaccSplitGetParent (split),
xaccAccountGetRoot (acc));
xaccAccountGetRoot (acc),
session);
}
}
void
xaccTransScrubOrphans (Transaction *trans, AccountGroup *root)
xaccTransScrubOrphans (Transaction *trans, AccountGroup *root,
GNCSession *session)
{
GList *node;
g_return_if_fail (session);
if (!trans)
return;
@ -126,7 +136,7 @@ xaccTransScrubOrphans (Transaction *trans, AccountGroup *root)
DEBUG ("Found an orphan \n");
orph = GetOrMakeAccount (root, trans, _("Orphan"));
orph = GetOrMakeAccount (root, trans, _("Orphan"), session);
if (!orph)
continue;
@ -248,11 +258,13 @@ xaccSplitScrub (Split *split)
/* ================================================================ */
void
xaccGroupScrubImbalance (AccountGroup *grp)
xaccGroupScrubImbalance (AccountGroup *grp, GNCSession *session)
{
GList *list;
GList *node;
g_return_if_fail (session);
if (!grp) return;
list = xaccGroupGetAccountList (grp);
@ -261,23 +273,30 @@ xaccGroupScrubImbalance (AccountGroup *grp)
{
Account *account = node->data;
xaccAccountTreeScrubImbalance (account);
xaccAccountTreeScrubImbalance (account, session);
}
}
void
xaccAccountTreeScrubImbalance (Account *acc)
xaccAccountTreeScrubImbalance (Account *acc, GNCSession *session)
{
xaccGroupScrubImbalance (xaccAccountGetChildren(acc));
xaccAccountScrubImbalance (acc);
g_return_if_fail (session);
xaccGroupScrubImbalance (xaccAccountGetChildren(acc), session);
xaccAccountScrubImbalance (acc, session);
}
void
xaccAccountScrubImbalance (Account *acc)
xaccAccountScrubImbalance (Account *acc, GNCSession *session)
{
GList *node;
const char *str;
g_return_if_fail (session);
if (!acc)
return;
str = xaccAccountGetName(acc);
str = str ? str : "(null)";
PINFO ("Looking for imbalance in account %s \n", str);
@ -287,17 +306,19 @@ xaccAccountScrubImbalance (Account *acc)
Split *split = node->data;
Transaction *trans = xaccSplitGetParent(split);
xaccTransScrubImbalance (trans, xaccAccountGetRoot (acc), NULL);
xaccTransScrubImbalance (trans, xaccAccountGetRoot (acc), NULL, session);
}
}
void
xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
Account *parent)
Account *parent, GNCSession *session)
{
Split *balance_split = NULL;
gnc_numeric imbalance;
g_return_if_fail (session);
if (!trans)
return;
@ -312,7 +333,7 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
return;
if (!parent)
account = GetOrMakeAccount (root, trans, _("Imbalance"));
account = GetOrMakeAccount (root, trans, _("Imbalance"), session);
else
account = parent;
@ -487,12 +508,14 @@ xaccGroupScrubCommodities (AccountGroup *group, GNCSession *session)
static Account *
GetOrMakeAccount (AccountGroup *root, Transaction *trans,
const char *name_root)
const char *name_root, GNCSession *session)
{
gnc_commodity * currency;
char * accname;
Account * acc;
g_return_val_if_fail (root, NULL);
/* build the account name */
currency = xaccTransGetCurrency (trans);
if (!currency)
@ -510,7 +533,7 @@ GetOrMakeAccount (AccountGroup *root, Transaction *trans,
if (acc == NULL)
{
/* guess not. We'll have to build one */
acc = xaccMallocAccount ();
acc = xaccMallocAccount (session);
xaccAccountBeginEdit (acc);
xaccAccountSetName (acc, accname);
xaccAccountSetCommodity (acc, currency);

View File

@ -37,8 +37,8 @@
#ifndef XACC_SCRUB_H
#define XACC_SCRUB_H
#include "Account.h"
#include "Group.h"
#include "gnc-engine.h"
/* The ScrubOrphans() methods search for transacations that contain
* splits that do not have a parent account. These "orphaned splits"
@ -58,10 +58,11 @@
* The xaccGroupScrubOrphans() method performs this scrub for the
* child accounts of this group.
*/
void xaccTransScrubOrphans (Transaction *trans, AccountGroup *root);
void xaccAccountScrubOrphans (Account *acc);
void xaccAccountTreeScrubOrphans (Account *acc);
void xaccGroupScrubOrphans (AccountGroup *grp);
void xaccTransScrubOrphans (Transaction *trans, AccountGroup *root,
GNCSession *session);
void xaccAccountScrubOrphans (Account *acc, GNCSession *session);
void xaccAccountTreeScrubOrphans (Account *acc, GNCSession *session);
void xaccGroupScrubOrphans (AccountGroup *grp, GNCSession *session);
/* The ScrubSplit methods ensure that splits with the same commodity
* and command currency have the same amount and value.
@ -78,10 +79,10 @@ void xaccGroupScrubSplits (AccountGroup *group);
* account.
*/
void xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
Account *parent);
void xaccAccountScrubImbalance (Account *acc);
void xaccAccountTreeScrubImbalance (Account *acc);
void xaccGroupScrubImbalance (AccountGroup *grp);
Account *parent, GNCSession *session);
void xaccAccountScrubImbalance (Account *acc, GNCSession *session);
void xaccAccountTreeScrubImbalance (Account *acc, GNCSession *session);
void xaccGroupScrubImbalance (AccountGroup *grp, GNCSession *session);
/* The xaccTransScrubCurrency method fixes transactions without a
* common_currency by using the old account currency and security

View File

@ -856,7 +856,7 @@ number of nanoseconds.")
'gnc:malloc-account
'<gnc:Account*>
"xaccMallocAccount"
'()
'((<gnc:Session*> session))
"Allocate a new account structure.")
(gw:wrap-function

View File

@ -462,7 +462,7 @@ get_random_account(GNCSession *session)
Account *ret;
int tmp_int;
ret = xaccMallocAccount();
ret = xaccMallocAccount(session);
xaccAccountBeginEdit(ret);

View File

@ -6,15 +6,12 @@
(define (run-test)
(gnc:module-system-init)
(gnc:module-load "gnucash/engine" 0)
(let ((group (gnc:malloc-account-group))
(acct (gnc:malloc-account)))
(let* ((session (gnc:session-new))
(group (gnc:malloc-account-group))
(acct (gnc:malloc-account session)))
(gnc:account-begin-edit acct)
(gnc:account-set-name acct "foo")
(gnc:account-commit-edit acct)
(gnc:group-insert-account group acct))
#t)

View File

@ -390,7 +390,8 @@ gnc_ui_to_account(AccountWindow *aw)
if (use_equity)
{
if (!gnc_account_create_opening_balance (account, balance, date))
if (!gnc_account_create_opening_balance (account, balance, date,
gnc_get_current_session ()))
{
const char *message = _("Could not create opening balance.");
gnc_error_dialog_parented(GTK_WINDOW(aw->dialog), message);
@ -433,7 +434,7 @@ gnc_finish_ok (AccountWindow *aw,
gnc_suspend_gui_refresh ();
parent = aw_get_account (aw);
account = xaccMallocAccount ();
account = xaccMallocAccount (gnc_get_current_session ());
aw->account = *xaccAccountGetGUID (account);
aw->type = xaccAccountGetType (parent);
@ -1415,7 +1416,7 @@ gnc_account_window_create(AccountWindow *aw)
box = glade_xml_get_widget (xml, "parent_scroll");
aw->top_level_account = xaccMallocAccount();
aw->top_level_account = xaccMallocAccount(gnc_get_current_session ());
xaccAccountSetName(aw->top_level_account, _("New top level account"));
aw->parent_tree = gnc_account_tree_new_with_root(aw->top_level_account);
@ -1614,7 +1615,7 @@ gnc_ui_new_account_window_internal (Account *base_account,
aw->dialog_type = NEW_ACCOUNT;
account = xaccMallocAccount ();
account = xaccMallocAccount (gnc_get_current_session ());
aw->account = *xaccAccountGetGUID (account);
if (base_account)

View File

@ -423,7 +423,7 @@ gnc_sx_create_from_trans(Transaction *trans)
sxfti->trans = trans;
sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_book ());
sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_session ());
sxfti_attach_callbacks(sxfti);

View File

@ -562,7 +562,7 @@ clone_account (const Account* from, gnc_commodity *com)
{
Account *ret;
ret = xaccCloneAccountSimple (from);
ret = xaccCloneAccountSimple (from, gnc_get_current_session ());
xaccAccountSetCommodity (ret, com);
@ -815,7 +815,8 @@ starting_balance_helper (Account *account, gpointer data)
balance = get_final_balance (account);
if (!gnc_numeric_zero_p (balance))
gnc_account_create_opening_balance (account, balance, time (NULL));
gnc_account_create_opening_balance (account, balance, time (NULL),
gnc_get_current_session ());
return NULL;
}

View File

@ -492,8 +492,8 @@ gnc_acct_tree_window_menu_scrub_cb(GtkWidget * widget,
gnc_suspend_gui_refresh ();
xaccAccountScrubOrphans (account);
xaccAccountScrubImbalance (account);
xaccAccountScrubOrphans (account, gnc_get_current_session ());
xaccAccountScrubImbalance (account, gnc_get_current_session ());
gnc_resume_gui_refresh ();
}
@ -514,8 +514,8 @@ gnc_acct_tree_window_menu_scrub_sub_cb(GtkWidget * widget,
gnc_suspend_gui_refresh ();
xaccAccountTreeScrubOrphans (account);
xaccAccountTreeScrubImbalance (account);
xaccAccountTreeScrubOrphans (account, gnc_get_current_session ());
xaccAccountTreeScrubImbalance (account, gnc_get_current_session ());
gnc_resume_gui_refresh ();
}
@ -527,8 +527,8 @@ gnc_acct_tree_window_menu_scrub_all_cb(GtkWidget * widget,
gnc_suspend_gui_refresh ();
xaccGroupScrubOrphans (group);
xaccGroupScrubImbalance (group);
xaccGroupScrubOrphans (group, gnc_get_current_session ());
xaccGroupScrubImbalance (group, gnc_get_current_session ());
gnc_resume_gui_refresh ();
}

View File

@ -1131,8 +1131,8 @@ gnc_recn_scrub_cb(GtkWidget *widget, gpointer data)
gnc_suspend_gui_refresh ();
xaccAccountTreeScrubOrphans (account);
xaccAccountTreeScrubImbalance (account);
xaccAccountTreeScrubOrphans (account, gnc_get_current_session ());
xaccAccountTreeScrubImbalance (account, gnc_get_current_session ());
gnc_resume_gui_refresh ();
}

View File

@ -1227,8 +1227,8 @@ gnc_register_scrub_all_cb (GtkWidget *widget, gpointer data)
Split *split = node->data;
Transaction *trans = xaccSplitGetParent (split);
xaccTransScrubOrphans (trans, root);
xaccTransScrubImbalance (trans, root, NULL);
xaccTransScrubOrphans (trans, root, gnc_get_current_session ());
xaccTransScrubImbalance (trans, root, NULL, gnc_get_current_session ());
}
gnc_resume_gui_refresh ();
@ -1252,8 +1252,8 @@ gnc_register_scrub_current_cb (GtkWidget *widget, gpointer data)
root = gnc_get_current_group ();
xaccTransScrubOrphans (trans, root);
xaccTransScrubImbalance (trans, root, NULL);
xaccTransScrubOrphans (trans, root, gnc_get_current_session ());
xaccTransScrubImbalance (trans, root, NULL, gnc_get_current_session ());
gnc_resume_gui_refresh ();
}

View File

@ -78,7 +78,7 @@
;; acct)
(if (and existing-account (compatible? existing-account))
existing-account
(let ((new-acct (gnc:malloc-account))
(let ((new-acct (gnc:malloc-account (gnc:get-current-session)))
(parent-acct #f)
(parent-name #f)
(acct-name #f)

View File

@ -37,6 +37,11 @@ gnc_module_init(void) {
return FALSE;
}
/* load the engine (we depend on it) */
if(!gnc_module_load("gnucash/app-utils", 0)) {
return FALSE;
}
/* load the QIF Scheme code */
if(gh_eval_str("(use-modules (gnucash qif-io core))") ==
SCM_BOOL_F) {

View File

@ -59,7 +59,7 @@
;; make the account if necessary
(if (not acct)
(begin
(set! acct (gnc:malloc-account))
(set! acct (gnc:malloc-account (gnc:get-current-session)))
(gnc:account-begin-edit acct)
(gnc:account-set-name acct acct-name)
(gnc:account-commit-edit acct)

View File

@ -159,7 +159,7 @@
;; make the account if necessary
(if (not acct)
(begin
(set! acct (gnc:malloc-account))
(set! acct (gnc:malloc-account (gnc:get-current-session)))
(gnc:account-set-name acct acct-name)
(qif-io:acct-table-insert! gnc-acct-info
acct-name acct-type acct)))

View File

@ -127,17 +127,18 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans)
break;
case 1:
xaccTransScrubImbalance (trans, gnc_get_current_group (), NULL);
xaccTransScrubImbalance (trans, gnc_get_current_group (), NULL,
gnc_get_current_session ());
break;
case 2:
xaccTransScrubImbalance (trans, gnc_get_current_group (),
default_account);
default_account, gnc_get_current_session ());
break;
case 3:
xaccTransScrubImbalance (trans, gnc_get_current_group (),
other_account);
other_account, gnc_get_current_session ());
break;
}