From: Manuel Nickschas Date: Thu, 21 Dec 2017 12:44:30 +0000 (+0100) Subject: Minor cleanups X-Git-Tag: travis-deploy-test~199 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=f353beded3963b67da6ac0878700dee8e61abfc4 Minor cleanups --- diff --git a/src/common/message.cpp b/src/common/message.cpp index a0e480a1..911c9353 100644 --- a/src/common/message.cpp +++ b/src/common/message.cpp @@ -21,8 +21,8 @@ #include "message.h" #include "util.h" -#include "signalproxy.h" #include "peer.h" +#include "signalproxy.h" #include diff --git a/src/common/peer.h b/src/common/peer.h index 34a56619..fbc17914 100644 --- a/src/common/peer.h +++ b/src/common/peer.h @@ -18,8 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef PEER_H -#define PEER_H +#pragma once #include #include @@ -27,8 +26,8 @@ #include "authhandler.h" #include "protocol.h" -#include "signalproxy.h" #include "quassel.h" +#include "signalproxy.h" class Peer : public QObject { @@ -145,5 +144,3 @@ void Peer::handle(const T &protoMessage) return; } } - -#endif diff --git a/src/common/protocol.h b/src/common/protocol.h index 45760801..e6266862 100644 --- a/src/common/protocol.h +++ b/src/common/protocol.h @@ -18,8 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef PROTOCOL_H_ -#define PROTOCOL_H_ +#pragma once #include #include @@ -57,7 +56,7 @@ struct HandshakeMessage { struct RegisterClient : public HandshakeMessage { - inline RegisterClient(const QString &clientVersion, const QString &buildDate, bool sslSupported = false, int32_t features = 0) + inline RegisterClient(const QString &clientVersion, const QString &buildDate, bool sslSupported = false, quint32 features = 0) : clientVersion(clientVersion) , buildDate(buildDate) , sslSupported(sslSupported) @@ -68,7 +67,7 @@ struct RegisterClient : public HandshakeMessage // this is only used by the LegacyProtocol in compat mode bool sslSupported; - int32_t clientFeatures; + quint32 clientFeatures; }; @@ -247,5 +246,3 @@ struct HeartBeatReply }; - -#endif diff --git a/src/common/remotepeer.cpp b/src/common/remotepeer.cpp index e25cbb3f..7c80406b 100644 --- a/src/common/remotepeer.cpp +++ b/src/common/remotepeer.cpp @@ -214,7 +214,6 @@ void RemotePeer::onReadyRead() processMessage(msg); - if (SignalProxy::current()) SignalProxy::current()->setSourcePeer(nullptr); } diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index bcc639fa..bf07f281 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -173,6 +173,9 @@ int SignalProxy::SignalRelay::qt_metacall(QMetaObject::Call _c, int _id, void ** // ================================================== // SignalProxy // ================================================== + +thread_local SignalProxy *SignalProxy::_current{nullptr}; + SignalProxy::SignalProxy(QObject *parent) : QObject(parent) { @@ -204,6 +207,8 @@ SignalProxy::~SignalProxy() _syncSlave.clear(); removeAllPeers(); + + _current = nullptr; } @@ -221,9 +226,6 @@ void SignalProxy::setProxyMode(ProxyMode mode) initClient(); } -thread_local SignalProxy *SignalProxy::_current; - - void SignalProxy::init() { _heartBeatInterval = 0; @@ -516,15 +518,9 @@ void SignalProxy::stopSynchronize(SyncableObject *obj) template void SignalProxy::dispatch(const T &protoMessage) { - for (auto peer : _peerMap.values()) { - _targetPeer = peer; - - if (peer->isOpen()) - peer->dispatch(protoMessage); - else - QCoreApplication::postEvent(this, new ::RemovePeerEvent(peer)); + for (auto&& peer : _peerMap.values()) { + dispatch(peer, protoMessage); } - _targetPeer = nullptr; } diff --git a/src/common/signalproxy.h b/src/common/signalproxy.h index 77ef3a46..ac4b8c6a 100644 --- a/src/common/signalproxy.h +++ b/src/common/signalproxy.h @@ -18,15 +18,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef SIGNALPROXY_H -#define SIGNALPROXY_H +#pragma once #include #include -#include #include -#include +#include #include "protocol.h" @@ -286,5 +284,3 @@ private: QHash _methodIds; QHash _receiveMap; // if slot x is called then hand over the result to slot y }; - -#endif