[FancyZones Editor] Crash when changing between zone layouts: refactoring (#12815)

This commit is contained in:
Seraphima Zykova
2021-08-23 18:20:04 +03:00
committed by GitHub
parent cea9b35319
commit e70994f121

View File

@@ -30,7 +30,6 @@ namespace FancyZonesEditor
private ContentDialog _openedDialog; private ContentDialog _openedDialog;
private TextBlock _createLayoutAnnounce; private TextBlock _createLayoutAnnounce;
private bool _openingDialog = false; // Is the dialog being opened.
public int WrapPanelItemSize { get; set; } = DefaultWrapPanelItemSize; public int WrapPanelItemSize { get; set; } = DefaultWrapPanelItemSize;
@@ -281,11 +280,11 @@ namespace FancyZonesEditor
private async void EditLayout_Click(object sender, RoutedEventArgs e) private async void EditLayout_Click(object sender, RoutedEventArgs e)
{ {
// Avoid trying to open the same dialog twice. // Avoid trying to open the same dialog twice.
if (!_openingDialog) if (_openedDialog != null)
{
_openingDialog = true;
try
{ {
return;
}
var dataContext = ((FrameworkElement)sender).DataContext; var dataContext = ((FrameworkElement)sender).DataContext;
Select((LayoutModel)dataContext); Select((LayoutModel)dataContext);
@@ -300,13 +299,6 @@ namespace FancyZonesEditor
await EditLayoutDialog.ShowAsync(); await EditLayoutDialog.ShowAsync();
} }
catch
{
_openingDialog = false;
throw;
}
}
}
private void EditZones_Click(object sender, RoutedEventArgs e) private void EditZones_Click(object sender, RoutedEventArgs e)
{ {
@@ -454,7 +446,6 @@ namespace FancyZonesEditor
private void Dialog_Closed(ContentDialog sender, ContentDialogClosedEventArgs args) private void Dialog_Closed(ContentDialog sender, ContentDialogClosedEventArgs args)
{ {
_openingDialog = false;
_openedDialog = null; _openedDialog = null;
} }