From 2ef09e3f02b5800bd8b527f35b7dd86d6547a8a6 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Thu, 14 Oct 2021 17:08:54 +0200 Subject: [PATCH] checking against divison by 0 --- src/controls/QskBoundedControl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controls/QskBoundedControl.cpp b/src/controls/QskBoundedControl.cpp index 1a116749..df38e5e0 100644 --- a/src/controls/QskBoundedControl.cpp +++ b/src/controls/QskBoundedControl.cpp @@ -144,7 +144,11 @@ qreal QskBoundedControl::boundedValue( qreal value ) const qreal QskBoundedControl::valueAsRatio( qreal value ) const { - return ( value - m_minimum ) / ( m_maximum - m_minimum ); + const auto range = m_maximum - m_minimum; + if ( qFuzzyIsNull( range ) ) + return 0.0; + + return ( value - m_minimum ) / range; } qreal QskBoundedControl::valueFromRatio( qreal ratio ) const