From 7be77847f9901223b8cd0a8f499033df66567af8 Mon Sep 17 00:00:00 2001 From: Umcaruje Date: Wed, 15 Mar 2017 09:36:57 +0100 Subject: [PATCH] Fix Overflow in Fader.cpp (#3425) * Fix Overflow in Fader.cpp --- src/gui/widgets/Fader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index 860625c47..a7a2d06fa 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -379,12 +379,12 @@ void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter) // Draw left levels - float const leftSpan = ampToDbfs(m_fPeakValue_L) - minDB; + float const leftSpan = ampToDbfs(qMax(0.0001, m_fPeakValue_L)) - minDB; int peak_L = height * leftSpan * fullSpanReciprocal; QRect drawRectL( 0, height - peak_L, width, peak_L ); // Source and target are identical painter.drawPixmap( drawRectL, *m_leds, drawRectL ); - float const persistentLeftPeakDBFS = ampToDbfs(m_persistentPeak_L); + float const persistentLeftPeakDBFS = ampToDbfs(qMax(0.0001, m_persistentPeak_L)); int persistentPeak_L = height * (1 - (persistentLeftPeakDBFS - minDB) * fullSpanReciprocal); // the LED's have a 4px padding and we don't want the peaks // to draw on the fader background @@ -401,12 +401,12 @@ void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter) // Draw right levels - float const rightSpan = ampToDbfs(m_fPeakValue_R) - minDB; + float const rightSpan = ampToDbfs(qMax(0.0001, m_fPeakValue_R)) - minDB; int peak_R = height * rightSpan * fullSpanReciprocal; QRect const drawRectR( center, height - peak_R, width, peak_R ); // Source and target are identical painter.drawPixmap( drawRectR, *m_leds, drawRectR ); - float const persistentRightPeakDBFS = ampToDbfs(m_persistentPeak_R); + float const persistentRightPeakDBFS = ampToDbfs(qMax(0.0001, m_persistentPeak_R)); int persistentPeak_R = height * (1 - (persistentRightPeakDBFS - minDB) * fullSpanReciprocal); // the LED's have a 4px padding and we don't want the peaks // to draw on the fader background