From 382fd9f4c1708a45615c952c428f86d6ef6cbce7 Mon Sep 17 00:00:00 2001 From: superpaik <68785450+superpaik@users.noreply.github.com> Date: Mon, 9 Oct 2023 23:06:55 +0200 Subject: [PATCH] Fix EQ effect warnings (#6655) * Fix warnings "QPainterPath::lineTo Invalid coordinates" on console when loading the effect or changing some paramenters, by not "drawing" the EQ curve when there is no EQ band active. * Fix warnings on console "QPainterPath::lineTo Invalid coordinates" when EQ is processing a sound, because in this function log10f generates a pole error when freq is 0, returning and invalid x value pixel * Update plugins/Eq/EqCurve.cpp --------- Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> --- plugins/Eq/EqCurve.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/Eq/EqCurve.cpp b/plugins/Eq/EqCurve.cpp index 10213bfa9..bb721a7e4 100644 --- a/plugins/Eq/EqCurve.cpp +++ b/plugins/Eq/EqCurve.cpp @@ -65,6 +65,7 @@ QRectF EqHandle::boundingRect() const float EqHandle::freqToXPixel( float freq , int w ) { + if (typeInfo::isEqual(freq, 0.0f)) { return 0.0f; } float min = log10f( 20 ); float max = log10f( 20000 ); float range = max - min; @@ -739,14 +740,18 @@ void EqCurve::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, } //compute a QPainterPath m_curve = QPainterPath(); - for ( int x = 0; x < m_width ; x++ ) + //only draw the EQ curve if there are any activeHandles + if (activeHandles != 0) { - mainCurve[x] = ( ( mainCurve[x] / activeHandles ) ) - ( m_heigth/2 ); - if ( x==0 ) + for (int x = 0; x < m_width; x++) { - m_curve.moveTo( x, mainCurve[x] ); + mainCurve[x] = ((mainCurve[x] / activeHandles)) - (m_heigth / 2); + if (x == 0) + { + m_curve.moveTo(x, mainCurve[x]); + } + m_curve.lineTo(x, mainCurve[x]); } - m_curve.lineTo( x, mainCurve[x] ); } //we cache the curve painting in a pixmap for saving cpu QPixmap cacheMap( boundingRect().size().toSize() );