From a045b10472a7800deb5db68938a9dfc783f7fc02 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Tue, 16 Sep 2014 08:42:36 +0200 Subject: [PATCH] OP-1481 fixed telemetry multi-threading issue: was not possible to create and request an uavo instance in one go --- .../openpilotgcs/src/plugins/uavtalk/telemetry.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp index 059d988b1..08c81e9e9 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp @@ -48,10 +48,12 @@ Telemetry::Telemetry(UAVTalk *utalk, UAVObjectManager *objMngr) : objMngr(objMng } // Listen to new object creations - connect(objMngr, SIGNAL(newObject(UAVObject *)), this, SLOT(newObject(UAVObject *))); - connect(objMngr, SIGNAL(newInstance(UAVObject *)), this, SLOT(newInstance(UAVObject *))); + // connection must be direct, if not, it is not possible to create and send (or request) an object in one go + connect(objMngr, SIGNAL(newObject(UAVObject *)), this, SLOT(newObject(UAVObject *)), Qt::DirectConnection); + connect(objMngr, SIGNAL(newInstance(UAVObject *)), this, SLOT(newInstance(UAVObject *)), Qt::DirectConnection); // Listen to transaction completions + // these slots will be executed in the telemetry thread // TODO should send a status (SUCCESS, FAILED, TIMEOUT) connect(utalk, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(transactionCompleted(UAVObject *, bool))); @@ -568,6 +570,10 @@ void Telemetry::newObject(UAVObject *obj) { QMutexLocker locker(mutex); +#ifdef VERBOSE_TELEMETRY + qDebug() << "Telemetry - new object" << obj->toStringBrief(); +#endif + registerObject(obj); } @@ -575,6 +581,10 @@ void Telemetry::newInstance(UAVObject *obj) { QMutexLocker locker(mutex); +#ifdef VERBOSE_TELEMETRY + qDebug() << "Telemetry - new object instance" << obj->toStringBrief(); +#endif + registerObject(obj); }