]> git.sesse.net Git - kdenlive/commitdiff
Audio spectrum: Fixed crash when the mouse cursor moved outside the widget while...
authorSimon A. Eugster <simon.eu@gmail.com>
Mon, 13 Dec 2010 08:20:09 +0000 (08:20 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Mon, 13 Dec 2010 08:20:09 +0000 (08:20 +0000)
svn path=/trunk/kdenlive/; revision=5171

src/audioscopes/audiospectrum.cpp

index 6122b7664ff2467500486da1e10deee71b46cf7e..ef8b44beb6871240dc6e1a12964a3900a4d9f76e 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <iostream>
 
-// Enables debugging, like writing a GNU Octave .m file to /tmp
+// Enables debugging
 //#define DEBUG_AUDIOSPEC
 
 #ifdef DEBUG_AUDIOSPEC
@@ -284,7 +284,9 @@ QImage AudioSpectrum::renderHUD(uint)
         bool drawDb = false;
 
         m_lastFFTLock.acquire();
-        if (m_lastFFT.size() > 0) {
+        // We need to test whether the mouse is inside the widget
+        // because the position could already have changed in the meantime (-> crash)
+        if (m_lastFFT.size() > 0 && mouseX >= 0 && mouseX < m_innerScopeRect.width()) {
             uint right = ((float) m_freqMax)/(m_freq) * (m_lastFFT.size() - 1);
             QVector<float> dbMap = AudioSpectrum::interpolatePeakPreserving(m_lastFFT, m_innerScopeRect.width(), 0, right, -120);