#include "gnome-vfs-method.h"
#include <libgnomevfs/gnome-vfs-module.h>
#include <glib/gmessages.h>
+#include <glib/gutils.h> /* for g_atexit() */
/* Are we initialized? */
G_LOCK_DEFINE(libcaptive);
+static void vfs_module_shutdown_atexit(void);
+
+
/**
* vfs_module_init:
* @method_name: FIXME
captive_gnomevfs_method_ptr=captive_gnomevfs_method_init(
args); /* captive_args */
+ g_atexit(vfs_module_shutdown_atexit);
+
active=TRUE;
return captive_gnomevfs_method_ptr;
}
+
/**
* vfs_module_shutdown:
- * @method:
*/
void vfs_module_shutdown(GnomeVFSMethod *method)
{
- g_return_if_fail(method!=NULL);
+ /* 'method' may be NULL iff we are called from vfs_module_shutdown_atexit() */
g_return_if_fail(active==TRUE);
+ captive_gnomevfs_method_shutdown();
+
active=FALSE;
}
+
+
+static void vfs_module_shutdown_atexit(void)
+{
+ if (active)
+ vfs_module_shutdown(NULL);
+}