core: Cancel nickname AutoWho on IrcUser quit
authorShane Synan <digitalcircuit36939@gmail.com>
Thu, 13 Sep 2018 06:34:44 +0000 (01:34 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 13 Sep 2018 21:46:02 +0000 (23:46 +0200)
Remove any queued AutoWho for <nickname> if <nickname> quits.  This
avoids sending a needless AutoWho for <nickname> that'll only either
result in "No such nickname" if we're lucky, or random results for
non-extended WHO if <nickname> happens to match the realname/etc of
other IRC users.

This should fix any remaining cases of join/quit resulting in AutoWho
output in the Status Buffer for a network.

src/core/corenetwork.cpp
src/core/corenetwork.h
src/core/coresessioneventprocessor.cpp

index fcafde4..395cb7a 100644 (file)
@@ -1322,6 +1322,16 @@ void CoreNetwork::queueAutoWhoOneshot(const QString &channelOrNick)
 }
 
 
+void CoreNetwork::cancelAutoWhoOneshot(const QString &channelOrNick)
+{
+    // Remove channel/nick from queue if it exists
+    _autoWhoQueue.removeAll(channelOrNick);
+
+    // The AutoWho timer will detect if the queue is empty and automatically stop, no need to
+    // manually control it.
+}
+
+
 void CoreNetwork::setAutoWhoDelay(int delay)
 {
     _autoWhoTimer.setInterval(delay * 1000);
index f2f7c4d..86fc4ab 100644 (file)
@@ -392,6 +392,18 @@ public slots:
      */
     void queueAutoWhoOneshot(const QString &channelOrNick);
 
+    /**
+     * Removes the given channel/nick from AutoWho queue for when it stops existing
+     *
+     * If not already in queue, nothing happens.  This should only be used for nicknames and
+     * channels that have suddenly stopped existing (e.g. nick joins then quits).
+     *
+     * For when a periodic channel AutoWho finishes, see CoreNetwork::setAutoWhoDone()
+     *
+     * @param channelOrNick Channel or nickname to WHO
+     */
+    void cancelAutoWhoOneshot(const QString &channelOrNick);
+
     bool setAutoWhoDone(const QString &channel);
 
     void updateIssuedModes(const QString &requestedModes);
index a461491..defee98 100644 (file)
@@ -753,6 +753,10 @@ void CoreSessionEventProcessor::lateProcessIrcEventQuit(IrcEvent *e)
     if (!ircuser)
         return;
 
+    // Clear the user from the AutoWho queue if in it
+    // This avoids needlessly checking a user that quickly joins then parts
+    coreNetwork(e)->cancelAutoWhoOneshot(ircuser->nick());
+
     ircuser->quit();
 }