From: Simon A. Eugster Date: Mon, 13 Dec 2010 08:20:09 +0000 (+0000) Subject: Audio spectrum: Fixed crash when the mouse cursor moved outside the widget while... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=775e3b8521a841f1cfc72a4e154e530f62c60505;p=kdenlive Audio spectrum: Fixed crash when the mouse cursor moved outside the widget while calculating svn path=/trunk/kdenlive/; revision=5171 --- diff --git a/src/audioscopes/audiospectrum.cpp b/src/audioscopes/audiospectrum.cpp index 6122b766..ef8b44be 100644 --- a/src/audioscopes/audiospectrum.cpp +++ b/src/audioscopes/audiospectrum.cpp @@ -20,7 +20,7 @@ #include -// 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 dbMap = AudioSpectrum::interpolatePeakPreserving(m_lastFFT, m_innerScopeRect.width(), 0, right, -120);