Browse Source

Avoid infinite recursion in input.range element. Fixes #202.

Michael Ragazzon 4 years ago
parent
commit
9d767bcc8a
1 changed files with 2 additions and 4 deletions
  1. 2 4
      Source/Core/Elements/WidgetSlider.cpp

+ 2 - 4
Source/Core/Elements/WidgetSlider.cpp

@@ -592,10 +592,8 @@ float WidgetSlider::SetValueInternal(float new_value)
 	parameters["value"] = value;
 	GetParent()->DispatchEvent(EventId::Change, parameters);
 
-
-	// TODO: This might not be the safest approach as this will call SetValue(), 
-	// thus, a slight mismatch will result in infinite recursion.
-	GetParent()->SetAttribute("value", value);
+	if (value != GetParent()->GetAttribute("value", 0.0f))
+		GetParent()->SetAttribute("value", value);
 
 	return (value - min_value) / (max_value - min_value);
 }