1 Star 0 Fork 50

常用工具/RabbitRemoteControl

forked from kl222/RabbitRemoteControl 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
PluginClientThread.cpp 2.18 KB
一键复制 编辑 原始数据 按行查看 历史
kl222 提交于 2025-02-17 17:06 +08:00 . Client: modify interfaces
#include "PluginClientThread.h"
#include <QLoggingCategory>
static Q_LOGGING_CATEGORY(log, "Client.Plugin.Thread")
CPluginClientThread::CPluginClientThread(QObject *parent)
: CPluginClient(parent),
m_pThread(nullptr)
{
m_pThread = new CPluginThread(); // Note that the parent object pointer cannot be set here.
if(m_pThread)
{
// The object is also deleted when the thread finishes executing.
bool check = connect(m_pThread, SIGNAL(finished()),
m_pThread, SLOT(deleteLater()));
Q_ASSERT(check);
m_pThread->start();
}
}
CPluginClientThread::~CPluginClientThread()
{
qDebug(log) << "CPluginClientThread::~CPluginClientThread";
if(m_pThread)
m_pThread->quit(); // The don't deleteLater().
// because of it is connected finished signal
}
CConnecter *CPluginClientThread::CreateConnecter(
const QString &szProtocol, CParameterClient *para)
{
qDebug(log) << "CPluginClientThread::CreateConnecter()" << szProtocol;
CConnecter* p = CPluginClient::CreateConnecter(szProtocol, para);
if(!p) return nullptr;
CConnecterConnect* pConnecter = qobject_cast<CConnecterConnect*>(p);
if(!pConnecter) {
QString szMsg = "Must be derived from CConnecterConnect*, Current is ";
szMsg += p->metaObject()->className();
szMsg += ";\nThe super class:\n";
auto super = p->metaObject()->superClass();
int n = 1;
while(super){
szMsg += QString(2 * n++, ' ') + "- ";
szMsg += super->className();
super = super->superClass();
}
qCritical(log) << szMsg;
Q_ASSERT(false);
return nullptr;
}
if(nullptr == m_pThread)
{
qDebug(log) << "The thread is nullptr";
return nullptr;
}
bool check = connect(pConnecter, SIGNAL(sigOpenConnect(CConnecterConnect*)),
m_pThread, SIGNAL(sigConnect(CConnecterConnect*)));
Q_ASSERT(check);
check = connect(pConnecter, SIGNAL(sigCloseconnect(CConnecterConnect*)),
m_pThread, SIGNAL(sigDisconnect(CConnecterConnect*)));
Q_ASSERT(check);
return pConnecter;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/common-tools/RabbitRemoteControl.git
git@gitee.com:common-tools/RabbitRemoteControl.git
common-tools
RabbitRemoteControl
RabbitRemoteControl
master

搜索帮助