mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Since QOF no longer keeps track of the "current" session,
qof_session_destroy() no longer clears the current session when we destroy it. Therefore, explicitly call gnc_clear_current_session() when we want to destroy the current session. Also, avoid accidentally creating a new book and session if there is no open book/current session when we run the bill reminder. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13378 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f04fccd5d0
commit
ee28ca912d
@ -2530,6 +2530,7 @@ gnc_invoice_remind_bills_due (void)
|
||||
GNCBook *book;
|
||||
gint days;
|
||||
|
||||
if (!gnc_current_session_exist()) return;
|
||||
book = qof_session_get_book(gnc_get_current_session());
|
||||
days = gnc_gconf_get_float(GCONF_SECTION_BILL, "days_in_advance", NULL);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "qof.h"
|
||||
#include "gnc-session.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "TransLog.h"
|
||||
|
||||
static QofSession * current_session = NULL;
|
||||
static QofLogModule log_module = GNC_MOD_ENGINE;
|
||||
@ -54,3 +55,13 @@ gnc_set_current_session (QofSession *session)
|
||||
PINFO("Leak of current session.");
|
||||
current_session = session;
|
||||
}
|
||||
|
||||
void gnc_clear_current_session()
|
||||
{
|
||||
if (current_session) {
|
||||
xaccLogDisable();
|
||||
qof_session_destroy(current_session);
|
||||
xaccLogEnable();
|
||||
current_session = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,6 @@
|
||||
#define gnc_session_get_url qof_session_get_url
|
||||
|
||||
QofSession * gnc_get_current_session (void);
|
||||
void gnc_clear_current_session(void);
|
||||
void gnc_set_current_session (QofSession *session);
|
||||
gboolean gnc_current_session_exist(void);
|
||||
|
||||
|
@ -501,26 +501,26 @@ gnc_file_new (void)
|
||||
if (!gnc_file_query_save (TRUE))
|
||||
return;
|
||||
|
||||
session = gnc_get_current_session ();
|
||||
if (gnc_current_session_exist()) {
|
||||
session = gnc_get_current_session ();
|
||||
|
||||
/* close any ongoing file sessions, and free the accounts.
|
||||
* disable events so we don't get spammed by redraws. */
|
||||
gnc_engine_suspend_events ();
|
||||
/* close any ongoing file sessions, and free the accounts.
|
||||
* disable events so we don't get spammed by redraws. */
|
||||
gnc_engine_suspend_events ();
|
||||
|
||||
qof_session_call_close_hooks(session);
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, session);
|
||||
|
||||
gnc_close_gui_component_by_session (session);
|
||||
xaccLogDisable();
|
||||
qof_session_destroy (session);
|
||||
xaccLogEnable();
|
||||
qof_session_call_close_hooks(session);
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, session);
|
||||
|
||||
gnc_close_gui_component_by_session (session);
|
||||
gnc_clear_current_session();
|
||||
gnc_engine_resume_events ();
|
||||
}
|
||||
|
||||
/* start a new book */
|
||||
gnc_get_current_session ();
|
||||
|
||||
|
||||
gnc_hook_run(HOOK_NEW_BOOK, NULL);
|
||||
|
||||
gnc_engine_resume_events ();
|
||||
|
||||
gnc_gui_refresh_all ();
|
||||
|
||||
/* Call this after re-enabling events. */
|
||||
@ -624,9 +624,7 @@ gnc_post_file_open (const char * filename)
|
||||
current_session = gnc_get_current_session();
|
||||
qof_session_call_close_hooks(current_session);
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, current_session);
|
||||
xaccLogDisable();
|
||||
qof_session_destroy (current_session);
|
||||
xaccLogEnable();
|
||||
gnc_clear_current_session();
|
||||
|
||||
/* load the accounts from the users datafile */
|
||||
/* but first, check to make sure we've got a session going. */
|
||||
@ -1064,9 +1062,7 @@ gnc_file_save_as (void)
|
||||
/* if we got to here, then we've successfully gotten a new session */
|
||||
/* close up the old file session (if any) */
|
||||
qof_session_swap_data (session, new_session);
|
||||
xaccLogDisable();
|
||||
qof_session_destroy (session);
|
||||
xaccLogEnable();
|
||||
gnc_clear_current_session();
|
||||
session = NULL;
|
||||
|
||||
/* XXX At this point, we should really mark the data in the new session
|
||||
@ -1116,9 +1112,7 @@ gnc_file_quit (void)
|
||||
qof_session_call_close_hooks(session);
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, session);
|
||||
|
||||
xaccLogDisable();
|
||||
qof_session_destroy (session);
|
||||
xaccLogEnable();
|
||||
gnc_clear_current_session();
|
||||
|
||||
gnc_get_current_session ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user