r18485 - gnucash/trunk/src/libqof/qof - Add qof_finalize_backend_libraries() which is called during shutdown. This routine checks each backend
Phil Longstaff
plongstaff at code.gnucash.org
Fri Dec 11 12:31:36 EST 2009
Author: plongstaff
Date: 2009-12-11 12:31:35 -0500 (Fri, 11 Dec 2009)
New Revision: 18485
Trac: http://svn.gnucash.org/trac/changeset/18485
Modified:
gnucash/trunk/src/libqof/qof/qofbackend.c
gnucash/trunk/src/libqof/qof/qofbackend.h
gnucash/trunk/src/libqof/qof/qofutil.c
Log:
Add qof_finalize_backend_libraries() which is called during shutdown. This routine checks each backend
library for an exported qof_backend_module_finalize() routine, and if it exists, calls it so that the
backend can free any resources which have been allocated.
Modified: gnucash/trunk/src/libqof/qof/qofbackend.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbackend.c 2009-12-11 08:54:06 UTC (rev 18484)
+++ gnucash/trunk/src/libqof/qof/qofbackend.c 2009-12-11 17:31:35 UTC (rev 18485)
@@ -502,6 +502,8 @@
}
}
+static GSList* backend_module_list = NULL;
+
gboolean
qof_load_backend_library (const char *directory, const char* module_name)
{
@@ -523,7 +525,25 @@
module_init_func();
g_module_make_resident(backend);
+ backend_module_list = g_slist_prepend( backend_module_list, backend );
return TRUE;
}
+void
+qof_finalize_backend_libraries(void)
+{
+ GSList* node;
+ GModule* backend;
+ void (*module_finalize_func) (void);
+
+ for (node = backend_module_list; node != NULL; node = node->next) {
+ backend = (GModule*)node->data;
+
+ if (g_module_symbol(backend, "qof_backend_module_finalize",
+ (gpointer)&module_finalize_func))
+ module_finalize_func();
+
+ }
+}
+
/************************* END OF FILE ********************************/
Modified: gnucash/trunk/src/libqof/qof/qofbackend.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbackend.h 2009-12-11 08:54:06 UTC (rev 18484)
+++ gnucash/trunk/src/libqof/qof/qofbackend.h 2009-12-11 17:31:35 UTC (rev 18485)
@@ -269,6 +269,9 @@
gboolean
qof_load_backend_library(const gchar *directory, const gchar* module_name);
+/** \brief Finalize all loaded backend sharable libraries. */
+void qof_finalize_backend_libraries(void);
+
/** \brief Retrieve the backend used by this book */
QofBackend* qof_book_get_backend (const QofBook *book);
Modified: gnucash/trunk/src/libqof/qof/qofutil.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofutil.c 2009-12-11 08:54:06 UTC (rev 18484)
+++ gnucash/trunk/src/libqof/qof/qofutil.c 2009-12-11 17:31:35 UTC (rev 18485)
@@ -523,6 +523,7 @@
qof_query_shutdown ();
qof_object_shutdown ();
guid_shutdown ();
+ qof_finalize_backend_libraries();
qof_util_string_cache_destroy ();
qof_log_shutdown();
}
More information about the gnucash-changes
mailing list