core: Fix CAP REQ display for SASL only supported
authorShane Synan <digitalcircuit36939@gmail.com>
Tue, 27 Feb 2018 19:50:43 +0000 (13:50 -0600)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 5 Apr 2018 22:04:54 +0000 (00:04 +0200)
Modify queuedCapsDisplay to only add a ", " when both
_capsQueuedIndividual and _capsQueuedBundled are not empty.  This
avoids adding a spurious ", " when there's only individual caps, e.g.
SASL.  Though the docs don't mention it, QStringList.join() will only
add the separator when there's more than one item in the list.

Before:
* Negotiating capabilities (requesting: sasl, )...
After:
* Negotiating capabilities (requesting: sasl)...

See https://doc.qt.io/qt-5/qstringlist.html#join

Closes GH-334.

src/core/corenetwork.cpp

index 24be4c1..198e114 100644 (file)
@@ -1210,9 +1210,10 @@ void CoreNetwork::beginCapNegotiation()
                tr("Ready to negotiate (found: %1)").arg(caps().join(", ")));
 
     // Build a list of queued capabilities, starting with individual, then bundled, only adding the
-    // comma separator between the two if needed.
+    // comma separator between the two if needed (both individual and bundled caps exist).
     QString queuedCapsDisplay =
-            (!_capsQueuedIndividual.empty() ? _capsQueuedIndividual.join(", ") + ", " : "")
+            _capsQueuedIndividual.join(", ")
+            + ((!_capsQueuedIndividual.empty() && !_capsQueuedBundled.empty()) ? ", " : "")
             + _capsQueuedBundled.join(", ");
     displayMsg(Message::Server, BufferInfo::StatusBuffer, "",
                tr("Negotiating capabilities (requesting: %1)...").arg(queuedCapsDisplay));