|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-07 15:43:18
|
Module: editor
Branch: master
Commit: 5c5d5095cdfcd550aedc75a3014cfc6bf18ada98
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Feb 7 16:42:00 2011 +0100
Fix hang when notes are loaded during audio analysis.
* Note graph timer was emitting a signal while holding a mutex
* The signal would later lead to acquiring of the same mutex => deadlock
---
notegraphwidget.cc | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 1bf17fb..f34e7b2 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -126,13 +126,21 @@ void NoteGraphWidget::timerEvent(QTimerEvent* event)
updateMusicPos(m_playbackPos);
} else if (event->timerId() == m_analyzeTimer && m_pitch) {
- QMutexLocker locker(&m_pitch->mutex);
- emit analyzeProgress(1000 * m_pitch->getProgress(), 1000);
- if (m_pitch->newDataAvailable()) {
- m_duration = std::max(m_duration, m_pitch->getDuration());
+ double progress, duration;
+ bool needUpdate, done;
+ {
+ QMutexLocker locker(&m_pitch->mutex);
+ progress = m_pitch->getProgress();
+ needUpdate = m_pitch->newDataAvailable();
+ duration = m_pitch->getDuration();
+ done = m_pitch->isFinished();
+ }
+ emit analyzeProgress(1000 * progress, 1000);
+ if (needUpdate) {
+ m_duration = std::max(m_duration, duration);
update();
}
- if (m_pitch->isFinished()) killTimer(m_analyzeTimer);
+ if (done) killTimer(m_analyzeTimer);
}
}
|