changeset 5151:ab2ae9dc9370

[gaim-migrate @ 5515] This fixes a crash using zephyr + any other account, and a crash keeping convo windows open after an account has disconnected, and a few other crashes, and a crash in some code Chip hasn't written yet ;-) committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 17 Apr 2003 23:42:47 +0000
parents 9a19c0a1e1be
children e637e36ee45c
files src/buddy.c src/prpl.c
diffstat 2 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy.c	Thu Apr 17 23:40:37 2003 +0000
+++ b/src/buddy.c	Thu Apr 17 23:42:47 2003 +0000
@@ -1782,7 +1782,20 @@
 	struct prpl *prpl = find_prpl(account->protocol);
 	GdkPixbuf *status = NULL;
 	char *filename = NULL;
-	const char *protoname = prpl->list_icon(account, NULL);
+	const char *protoname = NULL;
+
+	/* this is so we can get the icon when the prpl isn't loaded.
+	 * it's not as bad as it looks, since most of the time this function
+	 * is called, the prpl is already loaded, so it'll just increment and
+	 * decrement the refcount, won't have to go through the hassle of
+	 * actually loading and unloading the prpl.  the few times it actually
+	 * does that, it saves us from crashing */
+	if(prpl && prpl->list_icon) {
+		ref_protocol(prpl);
+		protoname = prpl->list_icon(account, NULL);
+		unref_protocol(prpl);
+	}
+
 	/* "Hey, what's all this crap?" you ask.  Status icons will be themeable too, and 
 	   then it will look up protoname from the theme */
 	if (!strcmp(protoname, "aim")) {
--- a/src/prpl.c	Thu Apr 17 23:40:37 2003 +0000
+++ b/src/prpl.c	Thu Apr 17 23:42:47 2003 +0000
@@ -853,7 +853,7 @@
 #ifdef GAIM_PLUGINS
 	if(p->plug) { /* This protocol is a plugin */
 		prpl_accounts[p->protocol]++;
-		debug_printf("Protocol %s now in use by %d connections.\n", p->name, prpl_accounts[p->protocol]);
+		debug_printf("Protocol %s refcount now %d\n", p->name, prpl_accounts[p->protocol]);
 		if(!p->plug->handle) { /*But the protocol isn't yet loaded */
 			unload_protocol(p);
 			if (load_prpl(p))
@@ -868,7 +868,7 @@
 #ifdef GAIM_PLUGINS
 	if(p->plug) { /* This protocol is a plugin */
 		prpl_accounts[p->protocol]--;
-		debug_printf("Protocol %s now in use by %d connections.\n", p->name, prpl_accounts[p->protocol]);
+		debug_printf("Protocol %s refcount now %d\n", p->name, prpl_accounts[p->protocol]);
 		if(prpl_accounts[p->protocol] == 0) { /* No longer needed */
 			debug_printf("Throwing out %s protocol plugin\n", p->name);
 			do_ask_cancel_by_handle(p->plug->handle);