Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for crash in host due to Preferences dialog #11790

Merged
merged 3 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

};

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