QT开发CTP代码段示例-多线程回收

QT5.7.1

p, li { white-space: pre-wrap; }

if(g_mapUsersData[UserID].pTrader == nullptr)
return;

if(g_mapUsersData[UserID].pThread == nullptr)
return;

g_mapUsersData[UserID].pTrader->deleteLater();
g_mapUsersData[UserID].pTrader->t_bRunning = false;
g_mapUsersData[UserID].pTrader = nullptr;

if(g_mapUsersData[UserID].pThread != nullptr)
{
if(g_mapUsersData[UserID].pThread->isRunning())
{
qDebug() << __FUNCTION__ << “isRunning”;
g_mapUsersData[UserID].pThread->exit(0);
//g_mapUsersData[UserID].pThread->destroyed();
g_mapUsersData[UserID].pThread->deleteLater();
g_mapUsersData[UserID].pThread->wait();
g_mapUsersData[UserID].pThread->quit();
delete g_mapUsersData[UserID].pThread;
g_mapUsersData[UserID].pThread = nullptr;
g_mapUsersData[UserID].pTrader = nullptr;

g_mapUsersData[UserID].pTrUserSpi = nullptr;
}
}