修改线程
This commit is contained in:
+33
-1
@@ -1091,11 +1091,43 @@ void MainWindow::updateUI()//事件驱动式更新数据
|
|||||||
case 5:
|
case 5:
|
||||||
gps_str.append(tr("float[%1颗]").arg(dlink->mavlinknode->vehicle.gps_raw_int.satellites_visible));
|
gps_str.append(tr("float[%1颗]").arg(dlink->mavlinknode->vehicle.gps_raw_int.satellites_visible));
|
||||||
break;
|
break;
|
||||||
|
case 6:
|
||||||
|
gps_str.append(tr("float[%1颗]").arg(dlink->mavlinknode->vehicle.gps_raw_int.satellites_visible));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
gps_str.append(tr("err[%1颗]").arg(dlink->mavlinknode->vehicle.gps_raw_int.satellites_visible));
|
gps_str.append(tr("%1[%2颗]").arg(dlink->mavlinknode->vehicle.gps_raw_int.fix_type).arg(dlink->mavlinknode->vehicle.gps_raw_int.satellites_visible));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch (dlink->mavlinknode->vehicle.gps_raw_int.fix_type) {
|
||||||
|
case 0:
|
||||||
|
gps_str.append(tr("UnKnow"));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
gps_str.append(tr("Unlocated"));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
gps_str.append(tr("%1D[%2颗]").arg(dlink->mavlinknode->vehicle.gps_raw_int.fix_type).arg(dlink->mavlinknode->vehicle.gps_raw_int.satellites_visible));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
gps_str.append(tr("DGPS"));
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
gps_str.append(tr("FLOAT"));
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
gps_str.append(tr("INT"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gps_str.append(tr("%1").arg(dlink->mavlinknode->vehicle.gps_raw_int.fix_type));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
copk->setGPS(gps_str);
|
copk->setGPS(gps_str);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ void terminal::start()
|
|||||||
thread = new QThread();
|
thread = new QThread();
|
||||||
this->moveToThread(thread);
|
this->moveToThread(thread);
|
||||||
connect(thread, &QThread::started, this, &terminal::process);
|
connect(thread, &QThread::started, this, &terminal::process);
|
||||||
|
connect(thread, &QThread::finished,thread,&QObject::deleteLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!thread->isRunning())
|
if(!thread->isRunning())
|
||||||
@@ -45,11 +46,13 @@ void terminal::stop()
|
|||||||
if(thread->isRunning())
|
if(thread->isRunning())
|
||||||
{
|
{
|
||||||
running_flag = false;
|
running_flag = false;
|
||||||
|
/*
|
||||||
qDebug() << "thread stop"
|
qDebug() << "thread stop"
|
||||||
<< QThread::currentThreadId()
|
<< QThread::currentThreadId()
|
||||||
<< QThread::currentThread()
|
<< QThread::currentThread()
|
||||||
<< "running state:"
|
<< "running state:"
|
||||||
<< running_flag;
|
<< running_flag;
|
||||||
|
*/
|
||||||
|
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
@@ -77,7 +80,7 @@ void terminal::process()//线程函数
|
|||||||
//qDebug() << count;
|
//qDebug() << count;
|
||||||
}
|
}
|
||||||
//退出线程
|
//退出线程
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
//disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
thread->quit();
|
thread->quit();
|
||||||
//thread->wait();//等待结束
|
//thread->wait();//等待结束
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
|
|||||||
@@ -48,11 +48,13 @@ void commandprocess::stop()
|
|||||||
if(thread->isRunning())
|
if(thread->isRunning())
|
||||||
{
|
{
|
||||||
running_flag = false;
|
running_flag = false;
|
||||||
|
/*
|
||||||
qDebug() << "thread stop"
|
qDebug() << "thread stop"
|
||||||
<< QThread::currentThreadId()
|
<< QThread::currentThreadId()
|
||||||
<< QThread::currentThread()
|
<< QThread::currentThread()
|
||||||
<< "running state:"
|
<< "running state:"
|
||||||
<< running_flag;
|
<< running_flag;
|
||||||
|
*/
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -50,18 +50,23 @@ MavLinkNode::MavLinkNode(QObject *parent) : QObject(parent)
|
|||||||
connect(thread, &QThread::finished,
|
connect(thread, &QThread::finished,
|
||||||
timer,&QTimer::stop),Qt::DirectConnection;
|
timer,&QTimer::stop),Qt::DirectConnection;
|
||||||
|
|
||||||
|
connect(thread, &QThread::finished,
|
||||||
|
timer,&QTimer::deleteLater),Qt::DirectConnection;
|
||||||
|
|
||||||
timer->start();
|
timer->start();
|
||||||
|
|
||||||
timer_1s = new QTimer();
|
timer_1s = new QTimer();
|
||||||
timer_1s->setInterval(1000);
|
timer_1s->setInterval(1000);
|
||||||
connect(timer_1s,&QTimer::timeout,
|
connect(timer_1s,&QTimer::timeout,
|
||||||
this,&MavLinkNode::timer_1s_Out,Qt::DirectConnection);
|
this,&MavLinkNode::timer_1s_Out,Qt::DirectConnection);
|
||||||
timer_1s->start();
|
|
||||||
|
|
||||||
connect(thread, &QThread::finished,
|
connect(thread, &QThread::finished,
|
||||||
timer_1s,&QTimer::stop),Qt::DirectConnection;
|
timer_1s,&QTimer::stop),Qt::DirectConnection;
|
||||||
|
|
||||||
|
connect(thread, &QThread::finished,
|
||||||
|
timer_1s,&QTimer::deleteLater),Qt::DirectConnection;
|
||||||
|
|
||||||
|
timer_1s->start();
|
||||||
|
|
||||||
|
|
||||||
hasConneted = false;
|
hasConneted = false;
|
||||||
@@ -174,8 +179,8 @@ MavLinkNode::~MavLinkNode()
|
|||||||
if(replay->isActive())
|
if(replay->isActive())
|
||||||
{
|
{
|
||||||
replay->stop();
|
replay->stop();
|
||||||
QThread::msleep(10);
|
|
||||||
delete replay;
|
replay->deleteLater();
|
||||||
replay = nullptr;
|
replay = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,7 +192,7 @@ MavLinkNode::~MavLinkNode()
|
|||||||
{
|
{
|
||||||
Mission->stop();
|
Mission->stop();
|
||||||
QThread::msleep(10);
|
QThread::msleep(10);
|
||||||
delete Mission;
|
Mission->deleteLater();
|
||||||
Mission = nullptr;
|
Mission = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,7 +204,7 @@ MavLinkNode::~MavLinkNode()
|
|||||||
{
|
{
|
||||||
Parameter->stop();
|
Parameter->stop();
|
||||||
QThread::msleep(10);
|
QThread::msleep(10);
|
||||||
delete Parameter;
|
Parameter->deleteLater();
|
||||||
Parameter = nullptr;
|
Parameter = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,7 +215,7 @@ MavLinkNode::~MavLinkNode()
|
|||||||
{
|
{
|
||||||
Commander->stop();//可能还没停止线程,后面不能紧跟着删除
|
Commander->stop();//可能还没停止线程,后面不能紧跟着删除
|
||||||
QThread::msleep(10);
|
QThread::msleep(10);
|
||||||
delete Commander;
|
Commander->deleteLater();
|
||||||
Commander = nullptr;
|
Commander = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,7 +226,7 @@ MavLinkNode::~MavLinkNode()
|
|||||||
{
|
{
|
||||||
Status->stop();//可能还没停止线程,后面不能紧跟着删除
|
Status->stop();//可能还没停止线程,后面不能紧跟着删除
|
||||||
QThread::msleep(10);
|
QThread::msleep(10);
|
||||||
delete Status;
|
Status->deleteLater();
|
||||||
Status = nullptr;
|
Status = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +237,7 @@ MavLinkNode::~MavLinkNode()
|
|||||||
{
|
{
|
||||||
Terminal->stop();//可能还没停止线程,后面不能紧跟着删除
|
Terminal->stop();//可能还没停止线程,后面不能紧跟着删除
|
||||||
QThread::msleep(10);
|
QThread::msleep(10);
|
||||||
delete Terminal;
|
Terminal->deleteLater();
|
||||||
Terminal = nullptr;
|
Terminal = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,11 +473,13 @@ void MavLinkNode::stop()
|
|||||||
|
|
||||||
|
|
||||||
running_flag = false;
|
running_flag = false;
|
||||||
|
/*
|
||||||
qDebug() << "thread stop"
|
qDebug() << "thread stop"
|
||||||
<< QThread::currentThreadId()
|
<< QThread::currentThreadId()
|
||||||
<< QThread::currentThread()
|
<< QThread::currentThread()
|
||||||
<< "running state:"
|
<< "running state:"
|
||||||
<< running_flag;
|
<< running_flag;
|
||||||
|
*/
|
||||||
|
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
@@ -516,7 +523,7 @@ void MavLinkNode::process()//线程函数
|
|||||||
}
|
}
|
||||||
running_flag = false;
|
running_flag = false;
|
||||||
//退出线程
|
//退出线程
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
//disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
thread->quit();
|
thread->quit();
|
||||||
//thread->wait();
|
//thread->wait();
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ void MissionProcess::start()
|
|||||||
thread = new QThread();
|
thread = new QThread();
|
||||||
this->moveToThread(thread);
|
this->moveToThread(thread);
|
||||||
connect(thread, &QThread::started, this, &MissionProcess::process);
|
connect(thread, &QThread::started, this, &MissionProcess::process);
|
||||||
|
connect(thread, &QThread::finished,thread,&QObject::deleteLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!thread->isRunning())
|
if(!thread->isRunning())
|
||||||
@@ -44,11 +45,13 @@ void MissionProcess::stop()
|
|||||||
if(thread->isRunning())
|
if(thread->isRunning())
|
||||||
{
|
{
|
||||||
running_flag = false;
|
running_flag = false;
|
||||||
|
/*
|
||||||
qDebug() << "thread stop"
|
qDebug() << "thread stop"
|
||||||
<< QThread::currentThreadId()
|
<< QThread::currentThreadId()
|
||||||
<< QThread::currentThread()
|
<< QThread::currentThread()
|
||||||
<< "running state:"
|
<< "running state:"
|
||||||
<< running_flag;
|
<< running_flag;
|
||||||
|
*/
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -87,7 +90,7 @@ void MissionProcess::process()//线程函数
|
|||||||
//qDebug() << count;
|
//qDebug() << count;
|
||||||
}
|
}
|
||||||
//退出线程
|
//退出线程
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
//disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
thread->quit();
|
thread->quit();
|
||||||
//thread->wait();//等待结束
|
//thread->wait();//等待结束
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ void ParameterProcess::start()
|
|||||||
thread = new QThread();
|
thread = new QThread();
|
||||||
this->moveToThread(thread);
|
this->moveToThread(thread);
|
||||||
connect(thread, &QThread::started, this, &ParameterProcess::process);
|
connect(thread, &QThread::started, this, &ParameterProcess::process);
|
||||||
|
connect(thread, &QThread::finished,thread,&QObject::deleteLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!thread->isRunning())
|
if(!thread->isRunning())
|
||||||
@@ -44,11 +45,13 @@ void ParameterProcess::stop()
|
|||||||
if(thread->isRunning())
|
if(thread->isRunning())
|
||||||
{
|
{
|
||||||
running_flag = false;
|
running_flag = false;
|
||||||
|
/*
|
||||||
qDebug() << "thread stop"
|
qDebug() << "thread stop"
|
||||||
<< QThread::currentThreadId()
|
<< QThread::currentThreadId()
|
||||||
<< QThread::currentThread()
|
<< QThread::currentThread()
|
||||||
<< "running state:"
|
<< "running state:"
|
||||||
<< running_flag;
|
<< running_flag;
|
||||||
|
*/
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -75,7 +78,7 @@ void ParameterProcess::process()//线程函数
|
|||||||
|
|
||||||
}
|
}
|
||||||
//退出线程
|
//退出线程
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
//disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
thread->quit();
|
thread->quit();
|
||||||
//thread->wait();//等待结束
|
//thread->wait();//等待结束
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ void Replay::start()
|
|||||||
thread = new QThread();
|
thread = new QThread();
|
||||||
this->moveToThread(thread);
|
this->moveToThread(thread);
|
||||||
connect(thread, SIGNAL(started()), this, SLOT(process()));
|
connect(thread, SIGNAL(started()), this, SLOT(process()));
|
||||||
|
connect(thread, &QThread::finished,thread,&QObject::deleteLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!thread->isRunning())
|
if(!thread->isRunning())
|
||||||
@@ -88,11 +89,13 @@ void Replay::stop()
|
|||||||
if(thread->isRunning())
|
if(thread->isRunning())
|
||||||
{
|
{
|
||||||
running_flag = false;
|
running_flag = false;
|
||||||
|
/*
|
||||||
qDebug() << "thread stop"
|
qDebug() << "thread stop"
|
||||||
<< QThread::currentThreadId()
|
<< QThread::currentThreadId()
|
||||||
<< QThread::currentThread()
|
<< QThread::currentThread()
|
||||||
<< "running state:"
|
<< "running state:"
|
||||||
<< running_flag;
|
<< running_flag;
|
||||||
|
*/
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -248,7 +251,7 @@ void Replay::process()//线程函数
|
|||||||
//mutex.unlock();
|
//mutex.unlock();
|
||||||
}
|
}
|
||||||
//退出线程
|
//退出线程
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
//disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
thread->quit();
|
thread->quit();
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
thread = nullptr;
|
thread = nullptr;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ void statusprocess::start()
|
|||||||
thread = new QThread();
|
thread = new QThread();
|
||||||
this->moveToThread(thread);
|
this->moveToThread(thread);
|
||||||
connect(thread, &QThread::started, this, &statusprocess::process);
|
connect(thread, &QThread::started, this, &statusprocess::process);
|
||||||
|
connect(thread, &QThread::finished,thread,&QObject::deleteLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!thread->isRunning())
|
if(!thread->isRunning())
|
||||||
@@ -47,11 +48,13 @@ void statusprocess::stop()
|
|||||||
if(thread->isRunning())
|
if(thread->isRunning())
|
||||||
{
|
{
|
||||||
running_flag = false;
|
running_flag = false;
|
||||||
|
/*
|
||||||
qDebug() << "thread stop"
|
qDebug() << "thread stop"
|
||||||
<< QThread::currentThreadId()
|
<< QThread::currentThreadId()
|
||||||
<< QThread::currentThread()
|
<< QThread::currentThread()
|
||||||
<< "running state:"
|
<< "running state:"
|
||||||
<< running_flag;
|
<< running_flag;
|
||||||
|
*/
|
||||||
|
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
@@ -90,9 +93,9 @@ void statusprocess::process()//线程函数
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//退出线程
|
//退出线程
|
||||||
disconnect(thread, nullptr, nullptr, nullptr);
|
//disconnect(thread, nullptr, nullptr, nullptr);
|
||||||
thread->quit();
|
thread->quit();
|
||||||
//thread->wait(200);//等待结束
|
//thread->wait();//等待结束
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
thread = nullptr;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user