1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-08-10 21:43:31 -04:00

gui: Explicitly call QSlider::setRange in LogSlider constructor

cppcheck identified that LogSlider::LogSlider() calls the derived
setRange(double, double) overload instead of QSlider::setRange(int, int)
due to C++ name hiding.

The constructor's call to:
    setRange(0, 1000);

was therefore invoking the logarithmic range implementation with
min == 0.0, resulting in a call to log10(0). While most callers
immediately replace the initial state by calling LogSlider::setRange()
with a valid positive range, the constructor still performs an invalid
mathematical operation during initialization.

Explicitly qualify the call as QSlider::setRange(0, 1000) to initialize
the underlying slider without invoking the logarithmic overload. This
eliminates the invalid-domain call, avoids undefined behavior from
propagating exceptional floating-point values into the slider state, and
makes the constructor's intent explicit.

This change has no functional impact on normal operation, but removes a
latent initialization bug and prevents future regressions caused by
overload hiding.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
This commit is contained in:
Robin Getz
2026-07-31 20:33:20 -04:00
parent d91046b2f0
commit 1253697801
+1 -1
View File
@@ -30,7 +30,7 @@
LogSlider::LogSlider(QWidget *parent) :
QSlider(Qt::Horizontal, parent)
{
setRange(0, 1000);
QSlider::setRange(0, 1000);
connect(this, &QSlider::valueChanged, this, &LogSlider::handleValueChanged);
setPageStep(1);
setTickPosition(QSlider::TicksAbove);