diff mcabber/src/roster.c @ 147:7571de4aed73

[/trunk] Changeset 159 by mikael * Fix a bug in buddylist_build() * We now lock the current buddy even not when being in chat mode. For example, if we're writing to s.o. and he leaves just before we press enter, we won't write to the wrong buddy... If the current_buddy is a group, we lock it too. * Remove MCABBER_TESTUNIT ifdef in roster.h (test program isn't up-to-date anymore...)
author mikael
date Fri, 29 Apr 2005 19:56:28 +0000
parents 6533a231a65e
children c3624b2a7059
line wrap: on
line diff
--- a/mcabber/src/roster.c	Fri Apr 29 18:35:05 2005 +0000
+++ b/mcabber/src/roster.c	Fri Apr 29 19:56:28 2005 +0000
@@ -305,7 +305,6 @@
   GSList *sl_roster_elt = groups;
   roster *roster_elt;
   roster *roster_current_buddy = NULL;
-  int pending_group;
   int shrunk_group;
 
   // We need to remember which buddy is selected.
@@ -323,14 +322,16 @@
   while (sl_roster_elt) {
     GSList *sl_roster_usrelt;
     roster *roster_usrelt;
+    guint pending_group = FALSE;
     roster_elt = (roster*) sl_roster_elt->data;
 
     // Add the group now unless hide_offline_buddies is set,
     // in which case we'll add it only if an online buddy belongs to it.
-    if (!hide_offline_buddies)
+    // We take care to keep the current_buddy in the list, too.
+    if (!hide_offline_buddies || roster_elt == roster_current_buddy)
       buddylist = g_list_append(buddylist, roster_elt);
     else
-       pending_group = TRUE;
+      pending_group = TRUE;
 
     shrunk_group = roster_elt->flags & ROSTER_FLAG_HIDE;
 
@@ -344,12 +345,14 @@
       // - buddy has a lock (for example the buddy window is currently open)
       // - buddy has a pending (non-read) message
       // - group isn't hidden (shrunk)
-      if (!hide_offline_buddies ||
+      // - this is the current_buddy
+      if (!hide_offline_buddies || roster_usrelt == roster_current_buddy ||
           (buddy_getstatus((gpointer)roster_usrelt) != offline) ||
           (buddy_getflags((gpointer)roster_usrelt) &
                (ROSTER_FLAG_LOCK | ROSTER_FLAG_MSG))) {
         // This user should be added.  Maybe the group hasn't been added yet?
-        if (hide_offline_buddies && pending_group) {
+        if (pending_group &&
+            (hide_offline_buddies || roster_usrelt == roster_current_buddy)) {
           // It hasn't been done yet
           buddylist = g_list_append(buddylist, roster_elt);
           pending_group = FALSE;