Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 committed Feb 5, 2024
1 parent 36dd65c commit ea9e968
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/UI/Prompts/CrashPrompt.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public CrashPrompt(CrashPromptArgs args, DynamoViewModel dynamoViewModel)
{
InitializeComponent();

var packageLoader = dynamoViewModel.Model.GetPackageManagerExtension()?.PackageLoader;
var packageLoader = dynamoViewModel?.Model?.GetPackageManagerExtension()?.PackageLoader;
markdownPackages = Wpf.Utilities.CrashUtilities.PackagesToMakrdown(packageLoader);

productName = dynamoViewModel.BrandingResourceProvider.ProductName;
productName = dynamoViewModel?.BrandingResourceProvider.ProductName ?? Process.GetCurrentProcess().ProcessName;
Title = string.Format(Wpf.Properties.Resources.CrashPromptDialogTitle, productName);
TitleTextBlock.Text = string.Format(Wpf.Properties.Resources.CrashPromptDialogTitle, productName);
txtOverridingText.Text = string.Format(Wpf.Properties.Resources.CrashPromptDialogCrashMessage, productName);
Expand Down
15 changes: 15 additions & 0 deletions src/DynamoCoreWpf/Utilities/CrashReportTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ private static string FindCERToolInInstallLocations()
}
}

internal static void ShowCrashWindow(object sender, CrashPromptArgs args)
{
var viewModel = sender as DynamoViewModel
;
if (CrashReportTool.ShowCrashErrorReportWindow(viewModel,
(args is CrashErrorReportArgs cerArgs) ? cerArgs :
new CrashErrorReportArgs(args.Details)))
{
return;
}
// Backup crash reporting dialog (in case ADSK CER is not found)
var prompt = new Nodes.Prompts.CrashPrompt(args, viewModel);
prompt.ShowDialog();
}

/// <summary>
/// Calls external CER tool (with UI)
/// </summary>
Expand Down
19 changes: 3 additions & 16 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ protected DynamoViewModel(StartConfiguration startConfiguration)
this.model = startConfiguration.DynamoModel;
this.model.CommandStarting += OnModelCommandStarting;
this.model.CommandCompleted += OnModelCommandCompleted;
this.model.RequestsCrashPrompt += Controller_RequestsCrashPrompt;
this.model.RequestsCrashPrompt += CrashReportTool.ShowCrashWindow;

this.HideReportOptions = startConfiguration.HideReportOptions;
UsageReportingManager.Instance.InitializeCore(this);
Expand Down Expand Up @@ -776,19 +776,6 @@ protected DynamoViewModel(StartConfiguration startConfiguration)
MLDataPipelineExtension = model.ExtensionManager.Extensions.OfType<DynamoMLDataPipelineExtension>().FirstOrDefault();
}

private void Controller_RequestsCrashPrompt(object sender, CrashPromptArgs args)
{
if (CrashReportTool.ShowCrashErrorReportWindow(this,
(args is CrashErrorReportArgs cerArgs) ? cerArgs :
new CrashErrorReportArgs(args.Details)))
{
return;
}
// Backup crash reporting dialog (in case ADSK CER is not found)
var prompt = new Nodes.Prompts.CrashPrompt(args, this);
prompt.ShowDialog();
}

private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
try
Expand Down Expand Up @@ -824,7 +811,7 @@ private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionE
}
}

internal void CrashGracefully(Exception ex, bool fatal = false)
private void CrashGracefully(Exception ex, bool fatal = false)
{
try
{
Expand Down Expand Up @@ -3585,7 +3572,7 @@ public bool PerformShutdownSequence(ShutdownParams shutdownParams)
AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
Dispatcher.CurrentDispatcher.UnhandledException -= CurrentDispatcher_UnhandledException;
TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException;
this.Model.RequestsCrashPrompt -= Controller_RequestsCrashPrompt;
this.Model.RequestsCrashPrompt -= CrashReportTool.ShowCrashWindow;

// Request the View layer to close its window (see
// ShutdownParams.CloseDynamoView member for details).
Expand Down

0 comments on commit ea9e968

Please sign in to comment.