X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fsessionthread.cpp;h=3347acc708f45bbcdc134afd186750da7b57ca9e;hp=7df83068ac86dc381f52a1b4e5a8bc6c2021ee0e;hb=c0d6dc0dec628f2e143e37ecc95cec45e636f8a5;hpb=ddfb1d2574c4bffd180361a80df9b1cd584bb040 diff --git a/src/core/sessionthread.cpp b/src/core/sessionthread.cpp index 7df83068..3347acc7 100644 --- a/src/core/sessionthread.cpp +++ b/src/core/sessionthread.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,6 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "sessionthread.h" + #include #include @@ -25,7 +27,6 @@ #include "coresession.h" #include "internalpeer.h" #include "remotepeer.h" -#include "sessionthread.h" #include "signalproxy.h" namespace { @@ -39,15 +40,14 @@ public: : _userId{userId} , _restoreState{restoreState} , _strictIdentEnabled{strictIdentEnabled} - { - } + {} public slots: void initialize() { _session = new CoreSession{_userId, _restoreState, _strictIdentEnabled, this}; - connect(_session, SIGNAL(destroyed()), QThread::currentThread(), SLOT(quit())); - connect(_session, SIGNAL(sessionState(Protocol::SessionState)), Core::instance(), SIGNAL(sessionState(Protocol::SessionState))); + connect(_session, &QObject::destroyed, QThread::currentThread(), &QThread::quit); + connect(_session, &CoreSession::sessionStateReceived, Core::instance(), &Core::sessionStateReceived); emit initialized(); } @@ -58,7 +58,7 @@ public slots: } } - void addClient(Peer *peer) + void addClient(Peer* peer) { if (!_session) { qWarning() << "Session not initialized!"; @@ -89,26 +89,25 @@ private: QPointer _session; }; -} // anon +} // namespace -SessionThread::SessionThread(UserId uid, bool restoreState, bool strictIdentEnabled, QObject *parent) +SessionThread::SessionThread(UserId uid, bool restoreState, bool strictIdentEnabled, QObject* parent) : QObject(parent) { auto worker = new Worker(uid, restoreState, strictIdentEnabled); worker->moveToThread(&_sessionThread); - connect(&_sessionThread, SIGNAL(started()), worker, SLOT(initialize())); - connect(&_sessionThread, SIGNAL(finished()), worker, SLOT(deleteLater())); - connect(worker, SIGNAL(initialized()), this, SLOT(onSessionInitialized())); - connect(worker, SIGNAL(destroyed()), this, SLOT(onSessionDestroyed())); + connect(&_sessionThread, &QThread::started, worker, &Worker::initialize); + connect(&_sessionThread, &QThread::finished, worker, &QObject::deleteLater); + connect(worker, &Worker::initialized, this, &SessionThread::onSessionInitialized); + connect(worker, &QObject::destroyed, this, &SessionThread::onSessionDestroyed); - connect(this, SIGNAL(addClientToWorker(Peer*)), worker, SLOT(addClient(Peer*))); - connect(this, SIGNAL(shutdownSession()), worker, SLOT(shutdown())); + connect(this, &SessionThread::addClientToWorker, worker, &Worker::addClient); + connect(this, &SessionThread::shutdownSession, worker, &Worker::shutdown); // Defer thread start through the event loop, so the SessionThread instance is fully constructed before QTimer::singleShot(0, &_sessionThread, SLOT(start())); } - SessionThread::~SessionThread() { // shut down thread gracefully @@ -116,17 +115,15 @@ SessionThread::~SessionThread() _sessionThread.wait(30000); } - void SessionThread::shutdown() { emit shutdownSession(); } - void SessionThread::onSessionInitialized() { _sessionInitialized = true; - for (auto &&peer : _clientQueue) { + for (auto&& peer : _clientQueue) { peer->setParent(nullptr); peer->moveToThread(&_sessionThread); emit addClientToWorker(peer); @@ -134,13 +131,12 @@ void SessionThread::onSessionInitialized() _clientQueue.clear(); } - void SessionThread::onSessionDestroyed() { emit shutdownComplete(this); } -void SessionThread::addClient(Peer *peer) +void SessionThread::addClient(Peer* peer) { if (_sessionInitialized) { peer->setParent(nullptr);