[Gnucash-changes] r13378 - gnucash/trunk/src - Since QOF no longer keeps track of the "current" session,

Chris Shoemaker chris at cvs.gnucash.org
Fri Feb 24 00:53:35 EST 2006


Author: chris
Date: 2006-02-24 00:53:35 -0500 (Fri, 24 Feb 2006)
New Revision: 13378
Trac: http://svn.gnucash.org/trac/changeset/13378

Modified:
   gnucash/trunk/src/business/business-gnome/dialog-invoice.c
   gnucash/trunk/src/engine/gnc-session.c
   gnucash/trunk/src/engine/gnc-session.h
   gnucash/trunk/src/gnome-utils/gnc-file.c
Log:
   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.


Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2006-02-24 05:13:51 UTC (rev 13377)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2006-02-24 05:53:35 UTC (rev 13378)
@@ -2530,6 +2530,7 @@
   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);
 

Modified: gnucash/trunk/src/engine/gnc-session.c
===================================================================
--- gnucash/trunk/src/engine/gnc-session.c	2006-02-24 05:13:51 UTC (rev 13377)
+++ gnucash/trunk/src/engine/gnc-session.c	2006-02-24 05:53:35 UTC (rev 13378)
@@ -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 @@
         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;
+    }
+}

Modified: gnucash/trunk/src/engine/gnc-session.h
===================================================================
--- gnucash/trunk/src/engine/gnc-session.h	2006-02-24 05:13:51 UTC (rev 13377)
+++ gnucash/trunk/src/engine/gnc-session.h	2006-02-24 05:53:35 UTC (rev 13378)
@@ -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);
-

Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c	2006-02-24 05:13:51 UTC (rev 13377)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c	2006-02-24 05:53:35 UTC (rev 13378)
@@ -501,26 +501,26 @@
   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);
+      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 ();
+  }
 
-  gnc_close_gui_component_by_session (session);
-  xaccLogDisable();
-  qof_session_destroy (session);
-  xaccLogEnable();
-
   /* 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 @@
   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 @@
   /* 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 @@
   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 ();
 



More information about the gnucash-changes mailing list