# HG changeset patch # User Eric Warmenhoven # Date 997121556 0 # Node ID af59d854de296ef356ae1777eb38896dd5c6ee4a # Parent a1922ad523044ed3e6219f89266e056de44d5718 [gaim-migrate @ 2135] bmiller's patch to unload plugins on exit signals committer: Tailor Script diff -r a1922ad52304 -r af59d854de29 src/aim.c --- a/src/aim.c Mon Aug 06 17:54:50 2001 +0000 +++ b/src/aim.c Mon Aug 06 18:12:36 2001 +0000 @@ -87,24 +87,11 @@ gtk_widget_hide(mainwindow); #else #ifdef GAIM_PLUGINS - GList *c; - struct gaim_plugin *p; - void (*gaim_plugin_remove)(); - /* first we tell those who have requested it we're quitting */ plugin_event(event_quit, 0, 0, 0, 0); /* then we remove everyone in a mass suicide */ - c = plugins; - while (c) { - p = (struct gaim_plugin *)c->data; - if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove)) - (*gaim_plugin_remove)(); - /* we don't need to worry about removing callbacks since - * there won't be any more chance to call them back :) */ - g_free(p); - c = c->next; - } + remove_all_plugins(); #endif /* GAIM_PLUGINS */ #ifdef USE_PERL perl_end(); @@ -406,8 +393,9 @@ abort(); break; default: + debug_printf("caught signal %d\n", sig); gtkspell_stop(); - debug_printf("caught signal %d\n", sig); + remove_all_plugins(); if (gtk_main_level()) gtk_main_quit(); exit(0); diff -r a1922ad52304 -r af59d854de29 src/buddy.c --- a/src/buddy.c Mon Aug 06 17:54:50 2001 +0000 +++ b/src/buddy.c Mon Aug 06 18:12:36 2001 +0000 @@ -1369,12 +1369,6 @@ void do_quit() { -#ifdef GAIM_PLUGINS - GList *c; - struct gaim_plugin *p; - void (*gaim_plugin_remove)(); -#endif - #ifdef USE_APPLET applet = NULL; #endif @@ -1384,16 +1378,7 @@ plugin_event(event_quit, 0, 0, 0, 0); /* then we remove everyone in a mass suicide */ - c = plugins; - while (c) { - p = (struct gaim_plugin *)c->data; - if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove)) - (*gaim_plugin_remove)(); - /* we don't need to worry about removing callbacks since - * there won't be any more chance to call them back :) */ - g_free(p); - c = c->next; - } + remove_all_plugins(); #endif system_log(log_quit, NULL, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); #ifdef USE_PERL diff -r a1922ad52304 -r af59d854de29 src/gaim.h --- a/src/gaim.h Mon Aug 06 17:54:50 2001 +0000 +++ b/src/gaim.h Mon Aug 06 18:12:36 2001 +0000 @@ -806,6 +806,7 @@ #endif extern char *event_name(enum gaim_event); extern int plugin_event(enum gaim_event, void *, void *, void *, void *); +extern void remove_all_plugins(); /* Functions in prefs.c */ extern void debug_printf( char * fmt, ... ); diff -r a1922ad52304 -r af59d854de29 src/plugins.c --- a/src/plugins.c Mon Aug 06 17:54:50 2001 +0000 +++ b/src/plugins.c Mon Aug 06 18:12:36 2001 +0000 @@ -981,3 +981,19 @@ return 0; #endif } + +/* Calls the gaim_plugin_remove function in any loaded plugin that has one */ +void remove_all_plugins() +{ + GList *c = plugins; + struct gaim_plugin *p; + void (*gaim_plugin_remove)(); + + while (c) { + p = (struct gaim_plugin *)c->data; + if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove)) + (*gaim_plugin_remove)(); + g_free(p); + c = c->next; + } +}