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_LOCKERR, /* mangled locks (unspecified error) */
|
||||||
ERR_FILEIO_FILE_NOT_FOUND, /* not found / no such file */
|
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_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 */
|
/* network errors */
|
||||||
ERR_NETIO_SHORT_READ = 2000, /* not enough bytes received */
|
ERR_NETIO_SHORT_READ = 2000, /* not enough bytes received */
|
||||||
|
@ -219,8 +219,8 @@ struct backend_s
|
|||||||
const char *book_id,
|
const char *book_id,
|
||||||
gboolean ignore_lock,
|
gboolean ignore_lock,
|
||||||
gboolean create_if_nonexistent);
|
gboolean create_if_nonexistent);
|
||||||
void (*book_load) (Backend *);
|
void (*book_load) (Backend *, GNCBook *);
|
||||||
void (*price_load) (Backend *);
|
void (*price_load) (Backend *, GNCBook *);
|
||||||
void (*session_end) (Backend *);
|
void (*session_end) (Backend *);
|
||||||
void (*destroy_backend) (Backend *);
|
void (*destroy_backend) (Backend *);
|
||||||
|
|
||||||
@ -238,9 +238,9 @@ struct backend_s
|
|||||||
|
|
||||||
void (*run_query) (Backend *, Query *);
|
void (*run_query) (Backend *, Query *);
|
||||||
void (*price_lookup) (Backend *, GNCPriceLookup *);
|
void (*price_lookup) (Backend *, GNCPriceLookup *);
|
||||||
void (*sync_all) (Backend *, GNCBook *book);
|
void (*sync_all) (Backend *, GNCBook *);
|
||||||
void (*sync_group) (Backend *, AccountGroup *);
|
void (*sync_group) (Backend *, GNCBook *);
|
||||||
void (*sync_price) (Backend *, GNCPriceDB *);
|
void (*sync_price) (Backend *, GNCBook *);
|
||||||
|
|
||||||
gboolean (*events_pending) (Backend *be);
|
gboolean (*events_pending) (Backend *be);
|
||||||
gboolean (*process_events) (Backend *be);
|
gboolean (*process_events) (Backend *be);
|
||||||
|
@ -355,6 +355,7 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
|||||||
gboolean
|
gboolean
|
||||||
gnc_session_load (GNCSession *session)
|
gnc_session_load (GNCSession *session)
|
||||||
{
|
{
|
||||||
|
GNCBook *oldbook;
|
||||||
Backend *be;
|
Backend *be;
|
||||||
|
|
||||||
if (!session) return FALSE;
|
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)
|
ENTER ("sess=%p book_id=%s", session, gnc_session_get_url(session)
|
||||||
? gnc_session_get_url(session) : "(null)");
|
? gnc_session_get_url(session) : "(null)");
|
||||||
|
|
||||||
|
|
||||||
/* At this point, we should are supposed to have a valid book
|
/* At this point, we should are supposed to have a valid book
|
||||||
* id and a lock on the file. */
|
* id and a lock on the file. */
|
||||||
|
|
||||||
xaccLogDisable();
|
oldbook = session->book;
|
||||||
|
|
||||||
gnc_book_set_backend (session->book, NULL);
|
|
||||||
gnc_book_destroy (session->book);
|
|
||||||
session->book = gnc_book_new ();
|
session->book = gnc_book_new ();
|
||||||
PINFO ("new book=%p", session->book);
|
PINFO ("new book=%p", session->book);
|
||||||
|
|
||||||
xaccLogSetBaseName(session->logpath);
|
xaccLogSetBaseName(session->logpath);
|
||||||
xaccLogEnable();
|
|
||||||
|
|
||||||
gnc_session_clear_error (session);
|
gnc_session_clear_error (session);
|
||||||
|
|
||||||
@ -397,16 +395,14 @@ gnc_session_load (GNCSession *session)
|
|||||||
|
|
||||||
if (be->book_load)
|
if (be->book_load)
|
||||||
{
|
{
|
||||||
xaccLogSetBaseName(session->logpath);
|
be->book_load (be, session->book);
|
||||||
|
|
||||||
be->book_load (be);
|
|
||||||
|
|
||||||
gnc_session_push_error (session, xaccBackendGetError(be), NULL);
|
gnc_session_push_error (session, xaccBackendGetError(be), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (be->price_load)
|
if (be->price_load)
|
||||||
{
|
{
|
||||||
be->price_load (be);
|
be->price_load (be, session->book);
|
||||||
|
|
||||||
gnc_session_push_error(session, xaccBackendGetError(be), NULL);
|
gnc_session_push_error(session, xaccBackendGetError(be), NULL);
|
||||||
}
|
}
|
||||||
@ -421,12 +417,14 @@ gnc_session_load (GNCSession *session)
|
|||||||
|
|
||||||
if (!gnc_book_get_group (session->book))
|
if (!gnc_book_get_group (session->book))
|
||||||
{
|
{
|
||||||
|
/* ?? should we restore the oldbook here ?? */
|
||||||
LEAVE("topgroup NULL");
|
LEAVE("topgroup NULL");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gnc_book_get_pricedb (session->book))
|
if (!gnc_book_get_pricedb (session->book))
|
||||||
{
|
{
|
||||||
|
/* ?? should we restore the oldbook here ?? */
|
||||||
LEAVE("pricedb NULL");
|
LEAVE("pricedb NULL");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -437,6 +435,11 @@ gnc_session_load (GNCSession *session)
|
|||||||
return FALSE;
|
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)
|
LEAVE ("sess = %p, book_id=%s", session, gnc_session_get_url(session)
|
||||||
? gnc_session_get_url(session) : "(null)");
|
? gnc_session_get_url(session) : "(null)");
|
||||||
|
|
||||||
@ -509,16 +512,16 @@ gnc_session_save (GNCSession *session)
|
|||||||
return;
|
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))
|
if (save_error_handler(be, session))
|
||||||
return;
|
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))
|
if(save_error_handler(be, session))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -526,7 +529,7 @@ gnc_session_save (GNCSession *session)
|
|||||||
return;
|
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. */
|
* or the lockfile was never obtained. Either way, we can't write. */
|
||||||
gnc_session_clear_error (session);
|
gnc_session_clear_error (session);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user