From c4b6b1618175a9a9e3ebdcd8de5bfdd81160c588 Mon Sep 17 00:00:00 2001 From: edouard Date: Fri, 7 Jan 2011 14:59:54 +0000 Subject: [PATCH] OP-242 : Fix notify crash on Linux. Additional check on phono media object in the playback callback to avoid race conditions. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2344 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/notify/notifyplugin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ground/src/plugins/notify/notifyplugin.cpp b/ground/src/plugins/notify/notifyplugin.cpp index 9809d4d5b..3e01c43d2 100644 --- a/ground/src/plugins/notify/notifyplugin.cpp +++ b/ground/src/plugins/notify/notifyplugin.cpp @@ -148,8 +148,10 @@ void SoundNotifyPlugin::connectNotifications() if (obj != NULL) disconnect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(appendNotification(UAVObject*))); } - if(phonon.mo != NULL) - delete phonon.mo; + if(phonon.mo != NULL) { + delete phonon.mo; + phonon.mo = NULL; + } if(!enableSound) return; @@ -287,6 +289,10 @@ void SoundNotifyPlugin::checkNotificationRule(NotifyPluginConfiguration* notific bool SoundNotifyPlugin::playNotification(NotifyPluginConfiguration* notification) { + // Check: race condition, if phonon.mo got deleted don't go further + if (phonon.mo == NULL) + return false; + #ifdef DEBUG_NOTIFIES qDebug() << "Phonon State: " << phonon.mo->state(); #endif