mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Slider: Avoid updating internal Value when old and new values are both NaN
Without this change in place, setting the Value to NaN can cause a stack overflow because the old and new values always compare unequal, causing new change notifications to be sent.
This commit is contained in:
parent
2a264390e8
commit
182dd84e59
1 changed files with 4 additions and 1 deletions
|
|
@ -225,7 +225,10 @@ public:
|
|||
// 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 (! approximatelyEqual (static_cast<double> (currentValue.getValue()), newValue))
|
||||
// We also want to avoid sending a notification if both new and old values are NaN.
|
||||
const auto asDouble = static_cast<double> (currentValue.getValue());
|
||||
|
||||
if (! (approximatelyEqual (asDouble, newValue) || (std::isnan (asDouble) && std::isnan (newValue))))
|
||||
currentValue = newValue;
|
||||
|
||||
updateText();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue