X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsignalproxy.cpp;h=5e5f59d497b449825c38f7aee30995cea37f06ff;hb=0216d4a650c02155b5bcd517567209f674d8a120;hp=f344603cbdc47b6d16fe9d7bb1ac3e213a7bd34b;hpb=68878dc8366f2f4a0afe132847aad9a51a80cdbf;p=quassel.git diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index f344603c..5e5f59d4 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -475,8 +475,11 @@ void SignalProxy::synchronize(SyncableObject *obj) void SignalProxy::detachObject(QObject *obj) { - detachSignals(obj); - detachSlots(obj); + // Don't try to connect SignalProxy from itself on shutdown + if (obj != this) { + detachSignals(obj); + detachSlots(obj); + } } @@ -847,7 +850,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)