[Gnucash-changes] r13355 - gnucash/trunk/src - Remove uses of
deprecated qof_session_get_current_session() and
Chris Shoemaker
chris at cvs.gnucash.org
Tue Feb 21 21:39:03 EST 2006
Author: chris
Date: 2006-02-21 21:39:02 -0500 (Tue, 21 Feb 2006)
New Revision: 13355
Trac: http://svn.gnucash.org/trac/changeset/13355
Added:
gnucash/trunk/src/engine/gnc-session.c
Modified:
gnucash/trunk/src/app-utils/gnc-ui-util.c
gnucash/trunk/src/app-utils/gw-app-utils-spec.scm
gnucash/trunk/src/business/business-gnome/dialog-invoice.c
gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
gnucash/trunk/src/engine/Makefile.am
gnucash/trunk/src/engine/gnc-session.h
gnucash/trunk/src/gnome-utils/gnc-file.c
gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
gnucash/trunk/src/gnome-utils/gnc-main-window.c
gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
Log:
Remove uses of deprecated qof_session_get_current_session() and
qof_session_set_current_session(). GnuCash now manages its own current
session. New function: gnc_current_session_exist() to test whether there
is a current session.
Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c 2006-02-22 02:39:02 UTC (rev 13355)
@@ -46,8 +46,8 @@
#include "Group.h"
#include "Transaction.h"
#include "guile-mappings.h"
+#include "gnc-session.h"
-
#define KEY_CURRENCY_CHOICE "currency_choice"
#define KEY_CURRENCY_OTHER "currency_other"
@@ -193,7 +193,7 @@
QofBook *
gnc_get_current_book (void)
{
- return qof_session_get_book (qof_session_get_current_session ());
+ return qof_session_get_book (gnc_get_current_session ());
}
AccountGroup *
Modified: gnucash/trunk/src/app-utils/gw-app-utils-spec.scm
===================================================================
--- gnucash/trunk/src/app-utils/gw-app-utils-spec.scm 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/app-utils/gw-app-utils-spec.scm 2006-02-22 02:39:02 UTC (rev 13355)
@@ -33,6 +33,7 @@
"#include <gnc-gettext-util.h>\n"
"#include <gnc-helpers.h>\n"
"#include <gnc-accounting-period.h>\n"
+ "#include <gnc-session.h>\n"
"#include <gnc-component-manager.h>\n")))
(gw:wrap-simple-type ws '<gnc:print-amount-info-scm> "GNCPrintAmountInfo"
@@ -71,7 +72,7 @@
ws
'gnc:get-current-session
'<gnc:Session*>
- "qof_session_get_current_session"
+ "gnc_get_current_session"
'()
"Get the current session.")
Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2006-02-22 02:39:02 UTC (rev 13355)
@@ -47,7 +47,7 @@
#include "window-report.h"
#include "dialog-search.h"
#include "search-param.h"
-
+#include "gnc-session.h"
#include "gncInvoice.h"
#include "gncInvoiceP.h"
@@ -2530,7 +2530,7 @@
GNCBook *book;
gint days;
- book = qof_session_get_book(qof_session_get_current_session());
+ book = qof_session_get_book(gnc_get_current_session());
days = gnc_gconf_get_float(GCONF_SECTION_BILL, "days_in_advance", NULL);
gnc_invoice_show_bills_due(book, days);
Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c 2006-02-22 02:39:02 UTC (rev 13355)
@@ -45,6 +45,7 @@
#include "gnc-date.h"
#include "gnc-file.h"
#include "guile-mappings.h"
+#include "gnc-session.h"
/* g_object functions */
static void gnc_plugin_business_class_init (GncPluginBusinessClass *klass);
@@ -716,7 +717,7 @@
gchar *filename;
gboolean success;
- current_session = qof_session_get_current_session();
+ current_session = gnc_get_current_session();
book = qof_session_get_book(current_session);
chart_session = qof_session_new();
success = FALSE;
@@ -739,7 +740,7 @@
GNC_FILE_DIALOG_EXPORT);
g_free(filename);
qof_session_end(chart_session);
- qof_session_set_current_session(current_session);
+ gnc_set_current_session(current_session);
}
static void
@@ -751,7 +752,7 @@
gchar *filename;
gboolean success;
- current_session = qof_session_get_current_session();
+ current_session = gnc_get_current_session();
book = qof_session_get_book(current_session);
chart_session = qof_session_new();
success = FALSE;
@@ -771,7 +772,7 @@
GNC_FILE_DIALOG_EXPORT);
qof_session_end(chart_session);
g_free(filename);
- qof_session_set_current_session(current_session);
+ gnc_set_current_session(current_session);
}
static void
@@ -783,7 +784,7 @@
gchar *filename;
gboolean success;
- current_session = qof_session_get_current_session();
+ current_session = gnc_get_current_session();
book = qof_session_get_book(current_session);
chart_session = qof_session_new();
success = FALSE;
@@ -803,7 +804,7 @@
GNC_FILE_DIALOG_EXPORT);
qof_session_end(chart_session);
g_free(filename);
- qof_session_set_current_session(current_session);
+ gnc_set_current_session(current_session);
}
static void
@@ -815,7 +816,7 @@
gchar *filename;
gboolean success;
- current_session = qof_session_get_current_session();
+ current_session = gnc_get_current_session();
book = qof_session_get_book(current_session);
chart_session = qof_session_new();
success = FALSE;
@@ -835,7 +836,7 @@
GNC_FILE_DIALOG_EXPORT);
qof_session_end(chart_session);
g_free(filename);
- qof_session_set_current_session(current_session);
+ gnc_set_current_session(current_session);
}
static void
Modified: gnucash/trunk/src/engine/Makefile.am
===================================================================
--- gnucash/trunk/src/engine/Makefile.am 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/engine/Makefile.am 2006-02-22 02:39:02 UTC (rev 13355)
@@ -37,6 +37,7 @@
gnc-hooks.c \
gnc-lot.c \
gnc-pricedb.c \
+ gnc-session.c \
gnc-session-scm.c \
gncmod-engine.c \
policy.c
Added: gnucash/trunk/src/engine/gnc-session.c
===================================================================
--- gnucash/trunk/src/engine/gnc-session.c 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/engine/gnc-session.c 2006-02-22 02:39:02 UTC (rev 13355)
@@ -0,0 +1,56 @@
+/*
+ * gnc-session.c -- GnuCash's session handling
+ *
+ * Copyright (C) 2006 Chris Shoemaker <c.shoemaker at cox.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation Voice: +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
+ * Boston, MA 02110-1301, USA gnu at gnu.org
+ */
+
+#include "config.h"
+#include "qof.h"
+#include "gnc-session.h"
+#include "gnc-engine.h"
+
+static QofSession * current_session = NULL;
+static QofLogModule log_module = GNC_MOD_ENGINE;
+
+QofSession *
+gnc_get_current_session (void)
+{
+ if (!current_session) {
+ qof_event_suspend();
+ current_session = qof_session_new ();
+ qof_event_resume();
+ }
+
+ return current_session;
+}
+
+gboolean
+gnc_current_session_exist(void)
+{
+ return (current_session != NULL);
+}
+
+void
+gnc_set_current_session (QofSession *session)
+{
+ if (current_session)
+ PINFO("Leak of current session.");
+ current_session = session;
+}
Modified: gnucash/trunk/src/engine/gnc-session.h
===================================================================
--- gnucash/trunk/src/engine/gnc-session.h 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/engine/gnc-session.h 2006-02-22 02:39:02 UTC (rev 13355)
@@ -1,5 +1,9 @@
#include "qof.h"
-#define gnc_get_current_session qof_session_get_current_session
#define gnc_session_get_url qof_session_get_url
+
+QofSession * gnc_get_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-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c 2006-02-22 02:39:02 UTC (rev 13355)
@@ -44,6 +44,7 @@
#include "gnc-plugin-file-history.h"
#include "qof.h"
#include "TransLog.h"
+#include "gnc-session.h"
#define GCONF_SECTION "dialogs/export_accounts"
@@ -487,7 +488,7 @@
static void
gnc_book_opened (void)
{
- gnc_hook_run(HOOK_BOOK_OPENED, qof_session_get_current_session());
+ gnc_hook_run(HOOK_BOOK_OPENED, gnc_get_current_session());
}
void
@@ -500,7 +501,7 @@
if (!gnc_file_query_save (TRUE))
return;
- session = qof_session_get_current_session ();
+ session = gnc_get_current_session ();
/* close any ongoing file sessions, and free the accounts.
* disable events so we don't get spammed by redraws. */
@@ -515,7 +516,7 @@
xaccLogEnable();
/* start a new book */
- qof_session_get_current_session ();
+ gnc_get_current_session ();
gnc_hook_run(HOOK_NEW_BOOK, NULL);
@@ -537,7 +538,7 @@
* up the file-selection dialog, we don't blow em out of the water;
* instead, give them another chance to say "no" to the verify box.
*/
- while (qof_book_not_saved(qof_session_get_book (qof_session_get_current_session ())))
+ while (qof_book_not_saved(qof_session_get_book (gnc_get_current_session ())))
{
GtkWidget *dialog;
gint response;
@@ -618,7 +619,7 @@
/* -------------- BEGIN CORE SESSION CODE ------------- */
/* -- this code is almost identical in FileOpen and FileSaveAs -- */
- current_session = qof_session_get_current_session();
+ current_session = gnc_get_current_session();
qof_session_call_close_hooks(current_session);
gnc_hook_run(HOOK_BOOK_CLOSED, current_session);
xaccLogDisable();
@@ -767,13 +768,14 @@
* reason, we don't want to leave them high & dry without a
* topgroup, because if the user continues, then bad things will
* happen. */
- qof_session_get_current_session ();
+ gnc_get_current_session ();
g_free (newfile);
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
+ /* CAS: This doesn't seem right. We failed. */
/* Call this after re-enabling events. */
gnc_book_opened ();
@@ -782,7 +784,7 @@
/* if we got to here, then we've successfully gotten a new session */
/* close up the old file session (if any) */
- qof_session_set_current_session(new_session);
+ gnc_set_current_session(new_session);
/* --------------- END CORE SESSION CODE -------------- */
@@ -820,7 +822,7 @@
* user fails to pick a file (by e.g. hitting the cancel button), we
* might be left with a null topgroup, which leads to nastiness when
* user goes to create their very first account. So create one. */
- qof_session_get_current_session ();
+ gnc_get_current_session ();
return result;
}
@@ -899,7 +901,7 @@
/* use the current session to save to file */
gnc_set_busy_cursor (NULL, TRUE);
- current_session = qof_session_get_current_session();
+ current_session = gnc_get_current_session();
gnc_window_show_progress(_("Exporting file..."), 0.0);
ok = qof_session_export (new_session, current_session,
gnc_window_show_progress);
@@ -933,7 +935,7 @@
/* hack alert -- Somehow make sure all in-progress edits get committed! */
/* If we don't have a filename/path to save to get one. */
- session = qof_session_get_current_session ();
+ session = gnc_get_current_session ();
if (!qof_session_get_file_path (session))
{
@@ -1007,7 +1009,7 @@
return;
}
- session = qof_session_get_current_session ();
+ session = gnc_get_current_session ();
oldfile = qof_session_get_file_path (session);
if (oldfile && (strcmp(oldfile, newfile) == 0))
{
@@ -1073,7 +1075,7 @@
* as being 'dirty', since we haven't saved it at all under the new
* session. But I'm lazy...
*/
- qof_session_set_current_session(new_session);
+ gnc_set_current_session(new_session);
/* --------------- END CORE SESSION CODE -------------- */
@@ -1107,7 +1109,7 @@
QofSession *session;
gnc_set_busy_cursor (NULL, TRUE);
- session = qof_session_get_current_session ();
+ session = gnc_get_current_session ();
/* disable events; otherwise the mass deletetion of accounts and
* transactions during shutdown would cause massive redraws */
@@ -1120,7 +1122,7 @@
qof_session_destroy (session);
xaccLogEnable();
- qof_session_get_current_session ();
+ gnc_get_current_session ();
gnc_engine_resume_events ();
gnc_unset_busy_cursor (NULL);
Modified: gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c 2006-02-22 02:39:02 UTC (rev 13355)
@@ -49,6 +49,7 @@
#include "dialog-commodity.h"
#include "dialog-totd.h"
#include "gnc-ui-util.h"
+#include "gnc-session.h"
#include <gnc-dir.h>
static QofLogModule log_module = GNC_MOD_GUI;
@@ -302,7 +303,7 @@
if (gtk_main_level() != 1)
return TRUE;
- session = qof_session_get_current_session ();
+ session = gnc_get_current_session ();
if (!session)
return TRUE;
Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c 2006-02-22 02:39:02 UTC (rev 13355)
@@ -811,7 +811,7 @@
"continue without saving these changes will be discarded.");
#endif
- session = qof_session_get_current_session();
+ session = gnc_get_current_session();
book = qof_session_get_book(session);
filename = qof_session_get_file_path(session);
if (filename == NULL)
@@ -890,7 +890,7 @@
if (g_list_length(active_windows) > 1)
return FALSE;
- session = qof_session_get_current_session();
+ session = gnc_get_current_session();
if (qof_book_not_saved(qof_session_get_book(session))) {
if (!gnc_main_window_prompt_for_save(GTK_WIDGET(window))) {
/* Tell gnucash to shutdown cleanly */
@@ -2697,7 +2697,7 @@
return;
}
- session = qof_session_get_current_session();
+ session = gnc_get_current_session();
if (qof_book_not_saved(qof_session_get_book(session))) {
if (gnc_main_window_prompt_for_save(GTK_WIDGET(window))) {
/* User canceled */
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c 2006-02-22 01:38:42 UTC (rev 13354)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c 2006-02-22 02:39:02 UTC (rev 13355)
@@ -43,6 +43,7 @@
#include "gnc-commodity.h"
#include "gnc-component-manager.h"
#include "gnc-engine.h"
+#include "gnc-session.h"
#include "gnc-icons.h"
#include "gnc-ui-util.h"
#include "dialog-utils.h"
@@ -1833,7 +1834,7 @@
Account *account;
QofBook *book;
- book = qof_session_get_book(qof_session_get_current_session());
+ book = qof_session_get_book(gnc_get_current_session());
account = xaccGetAccountFromFullName(xaccGetAccountGroup(book),
account_name,
gnc_get_account_separator());
@@ -1856,7 +1857,7 @@
Account *account;
QofBook *book;
- book = qof_session_get_book(qof_session_get_current_session());
+ book = qof_session_get_book(gnc_get_current_session());
account = xaccGetAccountFromFullName(xaccGetAccountGroup(book),
account_name,
gnc_get_account_separator());
More information about the gnucash-changes
mailing list