mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13355 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
66baad0f8e
commit
53cd1da9cf
@ -46,7 +46,7 @@
|
||||
#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 @@ gnc_extract_directory (char **dirname, const char *filename)
|
||||
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 *
|
||||
|
@ -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.")
|
||||
|
||||
|
@ -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 @@ gnc_invoice_remind_bills_due (void)
|
||||
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);
|
||||
|
@ -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 @@ gnc_plugin_business_cmd_export_invoice (GtkAction *action, GncMainWindowActionDa
|
||||
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_plugin_business_cmd_export_invoice (GtkAction *action, GncMainWindowActionDa
|
||||
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 @@ gnc_plugin_business_cmd_export_customer (GtkAction *action, GncMainWindowActionD
|
||||
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_plugin_business_cmd_export_customer (GtkAction *action, GncMainWindowActionD
|
||||
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 @@ gnc_plugin_business_cmd_export_vendor (GtkAction *action, GncMainWindowActionDat
|
||||
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_plugin_business_cmd_export_vendor (GtkAction *action, GncMainWindowActionDat
|
||||
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 @@ gnc_plugin_business_cmd_export_employee (GtkAction *action, GncMainWindowActionD
|
||||
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_plugin_business_cmd_export_employee (GtkAction *action, GncMainWindowActionD
|
||||
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
|
||||
|
@ -37,6 +37,7 @@ libgncmod_engine_la_SOURCES = \
|
||||
gnc-hooks.c \
|
||||
gnc-lot.c \
|
||||
gnc-pricedb.c \
|
||||
gnc-session.c \
|
||||
gnc-session-scm.c \
|
||||
gncmod-engine.c \
|
||||
policy.c
|
||||
|
56
src/engine/gnc-session.c
Normal file
56
src/engine/gnc-session.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* gnc-session.c -- GnuCash's session handling
|
||||
*
|
||||
* Copyright (C) 2006 Chris Shoemaker <c.shoemaker@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@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;
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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 @@ gnc_add_history (QofSession * session)
|
||||
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 @@ gnc_file_new (void)
|
||||
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 @@ gnc_file_new (void)
|
||||
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 @@ gnc_file_query_save (gboolean can_cancel)
|
||||
* 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 @@ gnc_post_file_open (const char * filename)
|
||||
|
||||
/* -------------- 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 @@ gnc_post_file_open (const char * filename)
|
||||
* 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 @@ gnc_post_file_open (const char * filename)
|
||||
|
||||
/* 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 @@ gnc_file_open (void)
|
||||
* 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 @@ gnc_file_export_file(const char * newfile)
|
||||
|
||||
/* 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 @@ gnc_file_save (void)
|
||||
/* 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 @@ gnc_file_save_as (void)
|
||||
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 @@ gnc_file_save_as (void)
|
||||
* 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 @@ gnc_file_quit (void)
|
||||
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 @@ gnc_file_quit (void)
|
||||
qof_session_destroy (session);
|
||||
xaccLogEnable();
|
||||
|
||||
qof_session_get_current_session ();
|
||||
gnc_get_current_session ();
|
||||
|
||||
gnc_engine_resume_events ();
|
||||
gnc_unset_busy_cursor (NULL);
|
||||
|
@ -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 @@ gnc_ui_check_events (gpointer not_used)
|
||||
if (gtk_main_level() != 1)
|
||||
return TRUE;
|
||||
|
||||
session = qof_session_get_current_session ();
|
||||
session = gnc_get_current_session ();
|
||||
if (!session)
|
||||
return TRUE;
|
||||
|
||||
|
@ -811,7 +811,7 @@ gnc_main_window_prompt_for_save (GtkWidget *window)
|
||||
"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 @@ gnc_main_window_delete_event (GtkWidget *window,
|
||||
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 @@ gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window)
|
||||
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 */
|
||||
|
@ -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 @@ tree_restore_expanded_row (GncTreeViewAccount *view,
|
||||
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 @@ tree_restore_selected_row (GncTreeViewAccount *view,
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user