summaryrefslogtreecommitdiffhomepage
path: root/tracker-s2bot/ftnoir_tracker_s2bot.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-07-20 23:13:15 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-07-20 23:13:15 +0200
commit83b474c4d084c27245a2b1a6790e371193caae3a (patch)
treeb6cef066473992eb844dbdb2ce7b53a51e66487f /tracker-s2bot/ftnoir_tracker_s2bot.cpp
parent32349f6b8cb6d6331df06749bcb29744df6e1ae2 (diff)
tracker/s2bot: fix stopping tracker
- need use QThread::exit to stop the event loop - QObject::moveToThread works when passed a working thread - stop QTimer in its thread
Diffstat (limited to 'tracker-s2bot/ftnoir_tracker_s2bot.cpp')
-rw-r--r--tracker-s2bot/ftnoir_tracker_s2bot.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/tracker-s2bot/ftnoir_tracker_s2bot.cpp b/tracker-s2bot/ftnoir_tracker_s2bot.cpp
index cb8afcdc..48220c5a 100644
--- a/tracker-s2bot/ftnoir_tracker_s2bot.cpp
+++ b/tracker-s2bot/ftnoir_tracker_s2bot.cpp
@@ -13,7 +13,7 @@ tracker_s2bot::tracker_s2bot() : pose { 0,0,0, 0,0,0 }, m_nam (std::make_unique<
tracker_s2bot::~tracker_s2bot()
{
- requestInterruption();
+ QThread::exit(0); // stop event loop
wait();
}
@@ -30,12 +30,12 @@ static const t bound(t datum, t least, t max)
void tracker_s2bot::run() {
if (s.freq == 0) s.freq = 10;
timer.setInterval(1000.0/s.freq);
- timer.setSingleShot(false);
+ timer.setSingleShot(false);
connect(&timer, &QTimer::timeout, [this]() {
auto reply = m_nam->get(QNetworkRequest(QUrl("http://localhost:17317/poll")));
connect(reply, &QNetworkReply::finished, [this, reply]() {
if (reply->error() == QNetworkReply::NoError) {
- //qDebug() << "Request submitted OK";
+ qDebug() << "Request submitted OK";
}
else {
qWarning() << "Request bounced:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) << reply->errorString();
@@ -80,14 +80,17 @@ void tracker_s2bot::run() {
reply->deleteLater();
});
});
+
timer.start();
exec();
+ timer.stop();
}
void tracker_s2bot::start_tracker(QFrame*)
{
start();
timer.moveToThread(this);
+ m_nam->moveToThread(this);
}
void tracker_s2bot::data(double *data)