changeset 26611:8a0797f40695

Apply patch from darkrain42 to fix the crash-on-exit. Hopefully, the order of shutdown is no longer broken now. Fixes #8774.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 10 Apr 2009 05:57:23 +0000
parents bd61f91e669a
children b87843de7c6a
files libpurple/core.c libpurple/plugin.c libpurple/plugin.h
diffstat 3 files changed, 35 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/core.c	Fri Apr 10 01:32:31 2009 +0000
+++ b/libpurple/core.c	Fri Apr 10 05:57:23 2009 +0000
@@ -216,15 +216,10 @@
 	/* The SSL plugins must be uninit before they're unloaded */
 	purple_ssl_uninit();
 
-	/* Unload all plugins before the UI because UI plugins might call
-	 * UI-specific functions */
-	purple_debug_info("main", "Unloading all plugins\n");
-	purple_plugins_destroy_all();
-
-	/* Shut down the UI before all the subsystems */
-	ops = purple_core_get_ui_ops();
-	if (ops != NULL && ops->quit != NULL)
-		ops->quit();
+	/* Unload all non-loader, non-prpl plugins before shutting down
+	 * subsystems. */
+	purple_debug_info("main", "Unloading normal plugins\n");
+	purple_plugins_unload(PURPLE_PLUGIN_STANDARD);
 
 	/* Save .xml files, remove signals, etc. */
 	purple_smileys_uninit();
@@ -247,7 +242,16 @@
 	purple_imgstore_uninit();
 	purple_network_uninit();
 
-	/* Everything after this must not try to read any prefs */
+	/* Everything after unloading all plugins must not fail if prpls aren't
+	 * around */
+	purple_debug_info("main", "Unloading all plugins\n");
+	purple_plugins_destroy_all();
+
+	ops = purple_core_get_ui_ops();
+	if (ops != NULL && ops->quit != NULL)
+		ops->quit();
+
+	/* Everything after prefs_uninit must not try to read any prefs */
 	purple_prefs_uninit();
 	purple_plugins_uninit();
 #ifdef HAVE_DBUS
@@ -255,7 +259,7 @@
 #endif
 
 	purple_cmds_uninit();
-	/* Everything after this cannot try to write things to the confdir */
+	/* Everything after util_uninit cannot try to write things to the confdir */
 	purple_util_uninit();
 	purple_log_uninit();
 
--- a/libpurple/plugin.c	Fri Apr 10 01:32:31 2009 +0000
+++ b/libpurple/plugin.c	Fri Apr 10 05:57:23 2009 +0000
@@ -1234,6 +1234,21 @@
 }
 
 void
+purple_plugins_unload(PurplePluginType type)
+{
+#ifdef PURPLE_PLUGINS
+	GList *l;
+
+	for (l = plugins; l; l = l->next) {
+		PurplePlugin *plugin = l->data;
+		if (plugin->info->type == type && purple_plugin_is_loaded(plugin))
+			purple_plugin_unload(plugin);
+	}
+
+#endif /* PURPLE_PLUGINS */
+}
+
+void
 purple_plugins_destroy_all(void)
 {
 #ifdef PURPLE_PLUGINS
--- a/libpurple/plugin.h	Fri Apr 10 01:32:31 2009 +0000
+++ b/libpurple/plugin.h	Fri Apr 10 05:57:23 2009 +0000
@@ -503,6 +503,11 @@
 void purple_plugins_unload_all(void);
 
 /**
+ * Unloads all plugins of a specific type.
+ */
+void purple_plugins_unload(PurplePluginType type);
+
+/**
  * Destroys all registered plugins.
  */
 void purple_plugins_destroy_all(void);