X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fsignalproxy.cpp;fp=src%2Fcommon%2Fsignalproxy.cpp;h=3ac73bc0bc10aaf9808374c1a114a1686d4e7b0f;hp=f344603cbdc47b6d16fe9d7bb1ac3e213a7bd34b;hb=ab8127d2193d7d9de9e41b9f454911fdd07e49df;hpb=744080e8b9e6d32aaeb3d08eaf1a576076735957 diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index f344603c..3ac73bc0 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -847,7 +847,10 @@ QVariantList SignalProxy::peerData() { } Peer *SignalProxy::peerById(int peerId) { - return _peerMap[peerId]; + // We use ::value() here instead of the [] operator because the latter has the side-effect + // of automatically inserting a null value with the passed key into the map. See + // https://doc.qt.io/qt-5/qhash.html#operator-5b-5d and https://doc.qt.io/qt-5/qhash.html#value. + return _peerMap.value(peerId); } void SignalProxy::restrictTargetPeers(QSet peers, std::function closure)