From a5fc50e704a4301b712d9a4a07664cb82bd41d84 Mon Sep 17 00:00:00 2001 From: zhangxusong <328180668@qq.com> Date: Thu, 19 Sep 2024 10:12:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BD=AC=E5=8F=91bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MavLinkNode/mavlinknode.cpp | 14 +++++++++----- MavLinkNode/mavlinknode.h | 6 +++++- dlink/dlink.cpp | 6 +++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/MavLinkNode/mavlinknode.cpp b/MavLinkNode/mavlinknode.cpp index b8963dd..35f1380 100644 --- a/MavLinkNode/mavlinknode.cpp +++ b/MavLinkNode/mavlinknode.cpp @@ -241,12 +241,11 @@ MavLinkNode::MavLinkNode(QObject *parent) : ThreadTemplet(parent) m_heartbeat.type = 0; - connect(&showInfoTimer, &QTimer::timeout, this, [this]() - { - infoExport(info); - }); + showInfoTimer = new QTimer; + showInfoTimer->setInterval(200); + connect(showInfoTimer, &QTimer::timeout, this, &MavLinkNode::showInfoTimerTimeout, Qt::DirectConnection); - showInfoTimer.start(200); + showInfoTimer->start(); } MavLinkNode::~MavLinkNode() @@ -2069,6 +2068,11 @@ void MavLinkNode::heartbeat(uint32_t custom_mode,uint8_t type,uint8_t autopilot, Send(msg); } +void MavLinkNode::showInfoTimerTimeout() +{ + infoExport(info); +} + void MavLinkNode::Transmit(QString msg) { diff --git a/MavLinkNode/mavlinknode.h b/MavLinkNode/mavlinknode.h index 2af9cae..4c3eb1e 100644 --- a/MavLinkNode/mavlinknode.h +++ b/MavLinkNode/mavlinknode.h @@ -24,6 +24,7 @@ #include "ParsePack.h" #include "QTime" #include "QDateTime" +#include #ifdef QtMavlinkNode #include @@ -356,8 +357,11 @@ protected: QDateTime *gpstimebase = nullptr; _showinfo info; - QTimer showInfoTimer; + QPointer showInfoTimer = nullptr; + +private slots: + void showInfoTimerTimeout(); }; #endif // MAVLINKNODE_H diff --git a/dlink/dlink.cpp b/dlink/dlink.cpp index f69719b..6c8f00e 100644 --- a/dlink/dlink.cpp +++ b/dlink/dlink.cpp @@ -1,4 +1,4 @@ -#include "dlink.h" +#include "dlink.h" #include #include "QDateTime" #include "QElapsedTimer" @@ -13,10 +13,10 @@ DLink::DLink(QObject *parent) : QObject(parent) //在当前线程运行 connect(mavlinknode,SIGNAL(SendMessageTo(quint8,quint8*,quint16)), - this,SLOT(SendMessageTo(quint8,quint8*,quint16)),Qt::BlockingQueuedConnection);//BlockingQueuedConnection);//信号和槽必须在不同的线程中,否则就产生死锁 + this,SLOT(SendMessageTo(quint8,quint8*,quint16)));//BlockingQueuedConnection);//信号和槽必须在不同的线程中,否则就产生死锁 connect(mavlinknode,SIGNAL(SendMessageToExport(quint8,quint8*,quint16)), - this,SLOT(SendMessageToExport(quint8,quint8*,quint16)),Qt::BlockingQueuedConnection);//BlockingQueuedConnection);//信号和槽必须在不同的线程中,否则就产生死锁 + this,SLOT(SendMessageToExport(quint8,quint8*,quint16)));//BlockingQueuedConnection);//信号和槽必须在不同的线程中,否则就产生死锁 //在当前线程运行