Skip to content

Commit ee45997

Browse files
rectified95Igor Klemenski
andauthored
Fix crash when step property is missing on Windows. (#259)
Co-authored-by: Igor Klemenski <[email protected]>
1 parent e7dd6ee commit ee45997

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/windows/SliderWindows/SliderView.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace winrt::SliderWindows::implementation {
8080
}
8181
else {
8282
updatedMaxValue = true;
83-
m_maxValue = propertyValue.AsInt64();
83+
m_maxValue = propertyValue.AsDouble();
8484
}
8585
}
8686
else if (propertyName == "minimumValue") {
@@ -89,16 +89,19 @@ namespace winrt::SliderWindows::implementation {
8989
}
9090
else {
9191
updatedMinValue = true;
92-
m_minValue = propertyValue.AsInt64();
92+
m_minValue = propertyValue.AsDouble();
9393
}
9494
}
9595
else if (propertyName == "step") {
9696
if (propertyValue.IsNull()) {
9797
this->ClearValue(xaml::Controls::Slider::StepFrequencyProperty());
9898
}
99-
else {
99+
else if (propertyValue.AsDouble() != 0) {
100100
this->StepFrequency(propertyValue.AsDouble());
101101
}
102+
else {
103+
this->StepFrequency(c_stepDefault);
104+
}
102105
}
103106
else if (propertyName == "inverted") {
104107
if (propertyValue.IsNull()) {

src/windows/SliderWindows/SliderView.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ namespace winrt::SliderWindows::implementation {
3535
winrt::Windows::Foundation::IInspectable const& sender,
3636
xaml::Input::ManipulationCompletedRoutedEventArgs const& args);
3737

38-
int64_t m_maxValue, m_minValue;
39-
double m_value;
38+
double m_value, m_maxValue, m_minValue;
39+
const double c_stepDefault = 0.1;
4040
};
4141
}
4242

0 commit comments

Comments
 (0)