mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
change backend API to fix book-bug
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6458 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
37d4cf0ae8
commit
3cab59040e
@ -67,7 +67,9 @@ typedef enum {
|
||||
ERR_FILEIO_FILE_LOCKERR, /* mangled locks (unspecified error) */
|
||||
ERR_FILEIO_FILE_NOT_FOUND, /* not found / no such file */
|
||||
ERR_FILEIO_FILE_TOO_OLD, /* file version so old we can't read it */
|
||||
ERR_FILEIO_UNKNOWN_FILE_TYPE,
|
||||
ERR_FILEIO_UNKNOWN_FILE_TYPE, /* didn't recognize the file type */
|
||||
ERR_FILEIO_PARSE_ERROR, /* couldn't parse the data in the file */
|
||||
ERR_FILEIO_BACKUP_ERROR, /* couldn't make a backup of the file */
|
||||
|
||||
/* network errors */
|
||||
ERR_NETIO_SHORT_READ = 2000, /* not enough bytes received */
|
||||
|
@ -219,8 +219,8 @@ struct backend_s
|
||||
const char *book_id,
|
||||
gboolean ignore_lock,
|
||||
gboolean create_if_nonexistent);
|
||||
void (*book_load) (Backend *);
|
||||
void (*price_load) (Backend *);
|
||||
void (*book_load) (Backend *, GNCBook *);
|
||||
void (*price_load) (Backend *, GNCBook *);
|
||||
void (*session_end) (Backend *);
|
||||
void (*destroy_backend) (Backend *);
|
||||
|
||||
@ -238,9 +238,9 @@ struct backend_s
|
||||
|
||||
void (*run_query) (Backend *, Query *);
|
||||
void (*price_lookup) (Backend *, GNCPriceLookup *);
|
||||
void (*sync_all) (Backend *, GNCBook *book);
|
||||
void (*sync_group) (Backend *, AccountGroup *);
|
||||
void (*sync_price) (Backend *, GNCPriceDB *);
|
||||
void (*sync_all) (Backend *, GNCBook *);
|
||||
void (*sync_group) (Backend *, GNCBook *);
|
||||
void (*sync_price) (Backend *, GNCBook *);
|
||||
|
||||
gboolean (*events_pending) (Backend *be);
|
||||
gboolean (*process_events) (Backend *be);
|
||||
|
@ -355,6 +355,7 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
gboolean
|
||||
gnc_session_load (GNCSession *session)
|
||||
{
|
||||
GNCBook *oldbook;
|
||||
Backend *be;
|
||||
|
||||
if (!session) return FALSE;
|
||||
@ -363,18 +364,15 @@ gnc_session_load (GNCSession *session)
|
||||
ENTER ("sess=%p book_id=%s", session, gnc_session_get_url(session)
|
||||
? gnc_session_get_url(session) : "(null)");
|
||||
|
||||
|
||||
/* At this point, we should are supposed to have a valid book
|
||||
* id and a lock on the file. */
|
||||
|
||||
xaccLogDisable();
|
||||
|
||||
gnc_book_set_backend (session->book, NULL);
|
||||
gnc_book_destroy (session->book);
|
||||
oldbook = session->book;
|
||||
session->book = gnc_book_new ();
|
||||
PINFO ("new book=%p", session->book);
|
||||
|
||||
xaccLogSetBaseName(session->logpath);
|
||||
xaccLogEnable();
|
||||
|
||||
gnc_session_clear_error (session);
|
||||
|
||||
@ -397,16 +395,14 @@ gnc_session_load (GNCSession *session)
|
||||
|
||||
if (be->book_load)
|
||||
{
|
||||
xaccLogSetBaseName(session->logpath);
|
||||
|
||||
be->book_load (be);
|
||||
be->book_load (be, session->book);
|
||||
|
||||
gnc_session_push_error (session, xaccBackendGetError(be), NULL);
|
||||
}
|
||||
|
||||
if (be->price_load)
|
||||
{
|
||||
be->price_load (be);
|
||||
be->price_load (be, session->book);
|
||||
|
||||
gnc_session_push_error(session, xaccBackendGetError(be), NULL);
|
||||
}
|
||||
@ -421,12 +417,14 @@ gnc_session_load (GNCSession *session)
|
||||
|
||||
if (!gnc_book_get_group (session->book))
|
||||
{
|
||||
/* ?? should we restore the oldbook here ?? */
|
||||
LEAVE("topgroup NULL");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gnc_book_get_pricedb (session->book))
|
||||
{
|
||||
/* ?? should we restore the oldbook here ?? */
|
||||
LEAVE("pricedb NULL");
|
||||
return FALSE;
|
||||
}
|
||||
@ -437,6 +435,11 @@ gnc_session_load (GNCSession *session)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xaccLogDisable();
|
||||
gnc_book_set_backend (oldbook, NULL);
|
||||
gnc_book_destroy (oldbook);
|
||||
xaccLogEnable();
|
||||
|
||||
LEAVE ("sess = %p, book_id=%s", session, gnc_session_get_url(session)
|
||||
? gnc_session_get_url(session) : "(null)");
|
||||
|
||||
@ -509,16 +512,16 @@ gnc_session_save (GNCSession *session)
|
||||
return;
|
||||
}
|
||||
|
||||
if (be->sync_group && gnc_book_get_group (session->book))
|
||||
if (be->sync_group)
|
||||
{
|
||||
(be->sync_group)(be, gnc_book_get_group (session->book));
|
||||
(be->sync_group)(be, session->book);
|
||||
if (save_error_handler(be, session))
|
||||
return;
|
||||
}
|
||||
|
||||
if (be->sync_price && gnc_book_get_pricedb (session->book))
|
||||
if (be->sync_price)
|
||||
{
|
||||
(be->sync_price)(be, gnc_book_get_pricedb (session->book));
|
||||
(be->sync_price)(be, session->book);
|
||||
if(save_error_handler(be, session))
|
||||
return;
|
||||
}
|
||||
@ -526,7 +529,7 @@ gnc_session_save (GNCSession *session)
|
||||
return;
|
||||
}
|
||||
|
||||
/* if the fullpath doesn't exist, either the user failed to initialize,
|
||||
/* If the fullpath doesn't exist, either the user failed to initialize,
|
||||
* or the lockfile was never obtained. Either way, we can't write. */
|
||||
gnc_session_clear_error (session);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user