From e3b6a29bfda3f60e4e3ba8cd0f164627c2b1638e Mon Sep 17 00:00:00 2001 From: pip Date: Sun, 27 Feb 2011 14:39:56 +0000 Subject: [PATCH] Possible fix for mutex lockups on GCS exit git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2905 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/plugins/uavtalk/telemetrymanager.cpp | 16 +++++++++------- .../src/plugins/uavtalk/telemetrymanager.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp index 1a2918baa..415293665 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp @@ -40,7 +40,9 @@ TelemetryManager::TelemetryManager() moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread()); - QMutexLocker locker(&mutex); // Pip + mutex = new QMutex(QMutex::Recursive); // Pip + + QMutexLocker locker(mutex); // Pip // Get UAVObjectManager instance ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -59,14 +61,14 @@ TelemetryManager::TelemetryManager() TelemetryManager::~TelemetryManager() { // Pip - mutex.lock(); + mutex->lock(); // deleteObjects(); - mutex.unlock(); + mutex->unlock(); } void TelemetryManager::onObjectDestroyed(QObject *obj) // Pip { - QMutexLocker locker(&mutex); + QMutexLocker locker(mutex); deleteObjects(); } @@ -78,7 +80,7 @@ void TelemetryManager::start(QIODevice *dev) void TelemetryManager::onStart() { - QMutexLocker locker(&mutex); // Pip + QMutexLocker locker(mutex); // Pip deleteObjects(); // Pip @@ -115,10 +117,10 @@ void TelemetryManager::stop() void TelemetryManager::onStop() { - mutex.lock(); // Pip + mutex->lock(); // Pip if (telemetryMon) telemetryMon->disconnect(this); deleteObjects(); - mutex.unlock(); + mutex->unlock(); onDisconnect(); } diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.h b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.h index 709c35b56..739277df2 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.h +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.h @@ -69,7 +69,7 @@ private: Telemetry* telemetry; TelemetryMonitor* telemetryMon; QIODevice *device; - QMutex mutex; + QMutex *mutex; void deleteObjects(); // Pip };