src: Yearly copyright bump
[quassel.git] / src / common / signalproxy.cpp
index bf07f28..9d3c04d 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2016 by the Quassel Project                        *
+ *   Copyright (C) 2005-2019 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -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);
+    }
 }
 
 
@@ -829,7 +832,7 @@ void SignalProxy::updateSecureState()
 
 QVariantList SignalProxy::peerData() {
     QVariantList result;
-    for (auto peer : _peerMap.values()) {
+    for (auto &&peer : _peerMap.values()) {
         QVariantMap data;
         data["id"] = peer->id();
         data["clientVersion"] = peer->clientVersion();
@@ -839,13 +842,18 @@ QVariantList SignalProxy::peerData() {
         data["remoteAddress"] = peer->address();
         data["connectedSince"] = peer->connectedSince();
         data["secure"] = peer->isSecure();
+        data["features"] = static_cast<quint32>(peer->features().toLegacyFeatures());
+        data["featureList"] = peer->features().toStringList();
         result << data;
     }
     return result;
 }
 
 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<Peer*> peers, std::function<void()> closure)