Skip to content

Commit 2d4673d

Browse files
committed
reject outdated data from settings (#2407)
1 parent 5d70621 commit 2d4673d

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/Calculator.ManagedViewModels/ApplicationViewModel.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,19 @@ public async Task ToggleAlwaysOnTop(double width, double height)
220220
}
221221
else
222222
{
223-
if (settings.Values.TryGetValue(WidthLocalSettingsKey, out var oldWidth) &&
224-
settings.Values.TryGetValue(HeightLocalSettingsKey, out var oldHeight))
223+
try
225224
{
226-
compactOptions.CustomSize = new Size((double)oldWidth, (double)oldHeight);
225+
if (settings.Values.TryGetValue(WidthLocalSettingsKey, out var oldWidth) &&
226+
settings.Values.TryGetValue(HeightLocalSettingsKey, out var oldHeight))
227+
{
228+
compactOptions.CustomSize = new Size((double)oldWidth, (double)oldHeight);
229+
}
230+
else
231+
{
232+
compactOptions.CustomSize = DefaultSize;
233+
}
227234
}
228-
else
235+
catch (InvalidCastException)
229236
{
230237
compactOptions.CustomSize = DefaultSize;
231238
}

0 commit comments

Comments
 (0)