Skip to content

Commit

Permalink
Fix for crash in host due to Preferences dialog (#11790)
Browse files Browse the repository at this point in the history
* fix for crash due to Preferences dialog

* cleanup

* removed unused usings
  • Loading branch information
aparajit-pratap authored Jun 25, 2021
1 parent 4125985 commit ab8b5a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ public PreferencesView(DynamoViewModel dynamoViewModel)
Actions.Open,
Categories.Preferences);

//If we want the PreferencesView window to be modal, we need to assign the owner (since we created a new Style and not following the common Style)
this.Owner = Application.Current.MainWindow;
var viewModelTemp = DataContext as PreferencesViewModel;
if (viewModelTemp != null)
if (DataContext is PreferencesViewModel viewModelTemp)
{
viewModel = viewModelTemp;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Input;
using Dynamo.UI;
using Dynamo.ViewModels;
using DynamoUtilities;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;

namespace Dynamo.Wpf.Views.PackageManager
{
Expand Down Expand Up @@ -69,8 +64,8 @@ private void OnRequestShowFileDialog(object sender, EventArgs e)
{
// Navigate to initial folder.
SelectedPath = args.Path,
Owner = System.Windows.Application.Current.Windows.OfType<PreferencesView>().SingleOrDefault(x => x.IsActive)
};
Owner = Window.GetWindow(this)
};

if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Expand Down

0 comments on commit ab8b5a1

Please sign in to comment.