Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
PluginClientThread.cpp
1#include "PluginClientThread.h"
2
3#include <QLoggingCategory>
4
5static Q_LOGGING_CATEGORY(log, "Client.Plugin.Thread")
6
8 : CPluginClient(parent),
9 m_pThread(nullptr)
10{
11 m_pThread = new CPluginThread(); // Note that the parent object pointer cannot be set here.
12 if(m_pThread)
13 {
14 // The object is also deleted when the thread finishes executing.
15 bool check = connect(m_pThread, SIGNAL(finished()),
16 m_pThread, SLOT(deleteLater()));
17 Q_ASSERT(check);
18 m_pThread->start();
19 }
20}
21
22CPluginClientThread::~CPluginClientThread()
23{
24 qDebug(log) << "CPluginClientThread::~CPluginClientThread";
25 if(m_pThread)
26 m_pThread->quit(); // The don't deleteLater().
27 // because of it is connected finished signal
28}
29
31{
32 qDebug(log) << "CPluginClientThread::CreateConnecter()" << szProtocol;
33 CConnecterConnect* pConnecter = OnCreateConnecter(szProtocol);
34 if(!pConnecter) return nullptr;
35
36 if(nullptr == m_pThread)
37 {
38 qDebug(log) << "The thread is nullptr";
39 return nullptr;
40 }
41
42 bool check = connect(pConnecter, SIGNAL(sigOpenConnect(CConnecterConnect*)),
43 m_pThread, SIGNAL(sigConnect(CConnecterConnect*)));
44 Q_ASSERT(check);
45 check = connect(pConnecter, SIGNAL(sigCloseconnect(CConnecterConnect*)),
46 m_pThread, SIGNAL(sigDisconnect(CConnecterConnect*)));
47 Q_ASSERT(check);
48
49 return pConnecter;
50}
The connector interface of the plug-in, which is only used by the plug-in.
Connecter interface.
Definition Connecter.h:62
It starts a background thread by default.
virtual CConnecterConnect * OnCreateConnecter(const QString &szProtocol)=0
Create Connecter.
virtual CConnecter * CreateConnecter(const QString &szProtocol) override
New CConnecter instance.
The plugin interface.
One thread handles multiple CConnecterConnect.