From 5544014b719d075412130f11acf7739b18e607c8 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 9 Aug 2024 20:26:46 -0700 Subject: [PATCH] Fix weird error message When creating a new project, we now put up a "save as" dialog. If you cancel out of the dialog, and have auto-save enabled, we post a strange message about being unable to create a file with an empty filename string. --- SourceGen/MainController.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index 6eda9c9..76141a1 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -890,8 +890,13 @@ namespace SourceGen { "' in favor of '" + pathName + "'"); DiscardRecoveryFile(); } - Debug.WriteLine("Recovery: creating '" + pathName + "'"); - PrepareRecoveryFile(); + if (!string.IsNullOrEmpty(pathName)) { + Debug.WriteLine("Recovery: creating '" + pathName + "'"); + PrepareRecoveryFile(); + } else { + // Must be a new project that has never been saved. + Debug.WriteLine("Recovery: project name not set, can't create recovery file"); + } } mAutoSaveTimer.Start(); } @@ -911,6 +916,7 @@ namespace SourceGen { /// private void PrepareRecoveryFile() { Debug.Assert(mRecoveryStream == null); + Debug.Assert(!string.IsNullOrEmpty(mProjectPathName)); Debug.Assert(string.IsNullOrEmpty(mRecoveryPathName)); string pathName = GenerateRecoveryPathName(mProjectPathName);