aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-29 19:08:16 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-29 19:08:16 +0200
commit2fe5eb939ff77697b578bf45ba23cd99daee9c5f (patch)
tree3a13b9bb3b9cde7fc81f325170a30daac1711688
parentb40e60db39f0b187774cfd2e0fe1b503f9bf1a54 (diff)
Clean up references from irc_user structs to channels that are being free()d.
-rw-r--r--irc.h4
-rw-r--r--irc_channel.c9
-rw-r--r--irc_im.c11
3 files changed, 21 insertions, 3 deletions
diff --git a/irc.h b/irc.h
index bbfeed82..9cacf13e 100644
--- a/irc.h
+++ b/irc.h
@@ -1,7 +1,7 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
- * Copyright 2002-2004 Wilmer van der Gaast and others *
+ * Copyright 2002-2010 Wilmer van der Gaast and others *
\********************************************************************/
/* The IRC-based UI (for now the only one) */
@@ -107,7 +107,7 @@ typedef struct irc_user
char *host;
char *fullname;
- /* Nickname in lowercase for case sensitive searches */
+ /* Nickname in lowercase for case insensitive searches */
char *key;
irc_user_flags_t flags;
diff --git a/irc_channel.c b/irc_channel.c
index 5d504f66..7d805014 100644
--- a/irc_channel.c
+++ b/irc_channel.c
@@ -116,6 +116,7 @@ irc_channel_t *irc_channel_get( irc_t *irc, char *id )
int irc_channel_free( irc_channel_t *ic )
{
irc_t *irc = ic->irc;
+ GSList *l;
if( ic->flags & IRC_CHANNEL_JOINED )
irc_channel_del_user( ic, irc->user, IRC_CDU_KICK, "Cleaning up channel" );
@@ -133,6 +134,14 @@ int irc_channel_free( irc_channel_t *ic )
ic->users = g_slist_remove( ic->users, ic->users->data );
}
+ for( l = irc->users; l; l = l->next )
+ {
+ irc_user_t *iu = l->data;
+
+ if( iu->last_channel == ic )
+ iu->last_channel = irc->default_channel;
+ }
+
g_free( ic->name );
g_free( ic->topic );
g_free( ic->topic_who );
diff --git a/irc_im.c b/irc_im.c
index d2898db4..465d8d20 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -209,13 +209,22 @@ static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, t
irc_user_t *iu = (irc_user_t *) bu->ui_data;
char *dst, *prefix = NULL;
char *wrapped, *ts = NULL;
+ irc_channel_t *ic = NULL;
if( sent_at > 0 && set_getbool( &irc->b->set, "display_timestamps" ) )
ts = irc_format_timestamp( irc, sent_at );
if( iu->last_channel )
{
- dst = iu->last_channel->name;
+ if( iu->last_channel->flags & IRC_CHANNEL_JOINED )
+ ic = iu->last_channel;
+ else if( irc->default_channel->flags & IRC_CHANNEL_JOINED )
+ ic = irc->default_channel;
+ }
+
+ if( ic )
+ {
+ dst = ic->name;
prefix = g_strdup_printf( "%s%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ), ts ? : "" );
}
else