changeset 7646:c8337162c712

[gaim-migrate @ 8289] "A masterpiece" says time magazine. Rolling Stone raves, "8 stars!" That guy gave it 4 thumbs up, and he only has 2 thumbs. This fixes "[ 849022 ] "gaim-remote quit" causes seg fault" http://sourceforge.net/tracker/index.php?func=detail&aid=849022&group_id=235&atid=100235 committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 27 Nov 2003 19:04:19 +0000
parents 28100686bde9
children 6a4d65df3f1c
files plugins/gaim-remote/remote.c src/core.c src/core.h
diffstat 3 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/gaim-remote/remote.c	Thu Nov 27 17:40:21 2003 +0000
+++ b/plugins/gaim-remote/remote.c	Thu Nov 27 19:04:19 2003 +0000
@@ -313,7 +313,7 @@
 			g_source_remove(ui->inpa);
 			g_free(ui);
 		}
-		gaim_core_quit();
+		g_timeout_add(0, gaim_core_quit_cb, NULL);
 		break;
 	case CUI_META_DETACH:
 		uis = g_slist_remove(uis, ui);
--- a/src/core.c	Thu Nov 27 17:40:21 2003 +0000
+++ b/src/core.c	Thu Nov 27 19:04:19 2003 +0000
@@ -145,6 +145,14 @@
 	_core = NULL;
 }
 
+gboolean
+gaim_core_quit_cb(gpointer unused)
+{
+	gaim_core_quit();
+
+	return FALSE;
+}
+
 const char *
 gaim_core_get_version(void)
 {
--- a/src/core.h	Thu Nov 27 17:40:21 2003 +0000
+++ b/src/core.h	Thu Nov 27 19:04:19 2003 +0000
@@ -57,6 +57,20 @@
 void gaim_core_quit(void);
 
 /**
+ * Calls gaim_core_quit().  This can be used as the function 
+ * passed to g_timeout_add() when you want to shutdown Gaim 
+ * in a specified amount of time.  When shutting down Gaim 
+ * from a plugin, you must use this with a timeout value of 0: 
+ *   g_timeout_add(0, gaim_core_quitcb, NULL);
+ * This is ensures that code from your plugin is not being 
+ * executed when gaim_core_quit() is called.  Otherwise you 
+ * would get a core dump after gaim_core_quit() executes and 
+ * control returns to your plugin because gaim_core_quit() frees 
+ * all plugins.
+ */
+gboolean gaim_core_quit_cb(gpointer unused);
+
+/**
  * Returns the version of the core library.
  *
  * @return The version of the core library.