From 7f0a305199bbe59eb0906aeb12e50471a55ed342 Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 18 Oct 2021 16:03:19 +0100 Subject: [PATCH] Slider: Ensure that current Value is always treated as a double --- modules/juce_gui_basics/widgets/juce_Slider.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 5062d5ed7a..6bf81244e4 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -191,9 +191,10 @@ public: lastCurrentValue = newValue; - // (need to do this comparison because the Value will use equalsWithSameType to compare - // the new and old values, so will generate unwanted change events if the type changes) - if (currentValue != newValue) + // Need to do this comparison because the Value will use equalsWithSameType to compare + // the new and old values, so will generate unwanted change events if the type changes. + // Cast to double before comparing, to prevent comparing as another type (e.g. String). + if (static_cast (currentValue.getValue()) != newValue) currentValue = newValue; updateText();