Decouple QofBook creation from QofSession.

So that we don't create two books when loading a session.
Step 1 to not having a dirty book when we think we should have no
book at all.
This commit is contained in:
John Ralls
2018-06-17 16:43:33 -07:00
parent 0a4347bd5e
commit 8ff5af4c19
21 changed files with 146 additions and 145 deletions

View File

@@ -224,4 +224,5 @@ char * no_args[1] = { NULL };
gnc_engine_init(0, no_args);
gnc_prefs_init();
%}
//We must explicitly declare this or it gets left out and we can't create books.
QofBook* qof_book_new (void);

View File

@@ -103,7 +103,7 @@ class Session(GnuCashCoreClass):
you don't need to cleanup and call end() and destroy(), that is handled
for you, and the exception is raised.
"""
GnuCashCoreClass.__init__(self, instance=instance)
GnuCashCoreClass.__init__(self, Book())
if book_uri is not None:
try:
self.begin(book_uri, ignore_lock, is_new, force_new)

View File

@@ -24,12 +24,15 @@
int main()
{
const char* testurl = "sqlite3://" TESTFILE;
char * no_args[1] = { NULL };
QofSession* s = NULL;
qof_log_init();
qof_init();
char * no_args[1] = { NULL };
gnc_engine_init(0, no_args);
QofSession * s = qof_session_new();
s = qof_session_new(NULL);
qof_session_begin(s, testurl, 0, 1, 0);
qof_session_load(s, NULL);
qof_session_save(s, NULL);