1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Fixed possible notification plugin deadlock

Protecting with mutex stateChanged(Phonon::State)
and starting/stopping playback looks dangerous,
the media player may emit another state change leading to deadlock.

The mutex should not be necessary here
since all the slots are executed in the main thread.

Changing the objectUpdated(UAVObject*) connection type
to Qt::QueuedConnection is not strictly necessary,
signals between threads are queued by default,
it serves more the documentation purpose.
This commit is contained in:
Dmytro Poplavskiy 2012-08-08 23:17:19 +10:00 committed by David Ankers
parent f4ff84d41a
commit d358591726
2 changed files with 3 additions and 6 deletions

View File

@ -206,7 +206,9 @@ void SoundNotifyPlugin::connectNotifications()
if (!lstNotifiedUAVObjects.contains(obj)) {
lstNotifiedUAVObjects.append(obj);
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(on_arrived_Notification(UAVObject*)));
connect(obj, SIGNAL(objectUpdated(UAVObject*)),
this, SLOT(on_arrived_Notification(UAVObject*)),
Qt::QueuedConnection);
}
} else {
qNotifyDebug() << "Error: Object is unknown (" << notify->getDataObject() << ").";
@ -297,8 +299,6 @@ void SoundNotifyPlugin::on_expiredTimer_Notification()
return;
notification->stopExpireTimer();
volatile QMutexLocker lock(&_mutex);
if (!_pendingNotifications.isEmpty()) {
qNotifyDebug() << QString("expireTimer: %1% | %2 | %3").arg(notification->getDataObject())
.arg(notification->getObjectField())
@ -327,7 +327,6 @@ void SoundNotifyPlugin::stateChanged(Phonon::State newstate, Phonon::State oldst
{
qNotifyDebug() << "New State: " << QVariant(newstate).toString();
volatile QMutexLocker lock(&_mutex);
// assignment to NULL needed to detect that palying is finished
// it's useful in repeat timer handler, where we can detect
// that notification has not overlap with itself
@ -442,7 +441,6 @@ void SoundNotifyPlugin::checkNotificationRule(NotificationItem* notification, UA
}
if(notification->retryValue() == NotificationItem::repeatOncePerUpdate && notification->getCurrentUpdatePlayed())
return;
volatile QMutexLocker lock(&_mutex);
if (!playNotification(notification)) {
if (!_pendingNotifications.contains(notification)

View File

@ -101,7 +101,6 @@ private:
PhononObject phonon;
NotifyPluginOptionsPage* mop;
TelemetryManager* telMngr;
QMutex _mutex;
};
#endif // SOUNDNOTIFYPLUGIN_H