From f9c8758742eaed26d75ebce83928e54853818eea Mon Sep 17 00:00:00 2001 From: Philiquaz Date: Mon, 1 Jul 2024 21:10:11 +0100 Subject: [PATCH] Fix doublecrash when lastProjectFile isn't defined --- src/StudioCore/MapStudioNew.cs | 8 +++++--- src/StudioCore/Project.cs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/StudioCore/MapStudioNew.cs b/src/StudioCore/MapStudioNew.cs index 23ed73aac..ba4f3280e 100644 --- a/src/StudioCore/MapStudioNew.cs +++ b/src/StudioCore/MapStudioNew.cs @@ -620,7 +620,7 @@ private bool StealGameDllIfMissing(ProjectSettings settings, string dllName) public void SaveAll() { - if (_projectSettings != null && _projectSettings.ProjectName != null) + if (_projectSettings != null && _projectSettings.ProjectName != null && !string.IsNullOrWhiteSpace(CFG.Current.LastProjectFile)) { // Danger zone assuming on lastProjectFile _projectSettings.Serialize(CFG.Current.LastProjectFile); @@ -672,8 +672,10 @@ private void SaveFocusedEditor() { if (_projectSettings != null && _projectSettings.ProjectName != null) { - // Danger zone assuming on lastProjectFile - _projectSettings.Serialize(CFG.Current.LastProjectFile); + if (!string.IsNullOrWhiteSpace(CFG.Current.LastProjectFile)) + { + _projectSettings.Serialize(CFG.Current.LastProjectFile); + } _focusedEditor.Save(); } } diff --git a/src/StudioCore/Project.cs b/src/StudioCore/Project.cs index a5660aa9f..c4854606b 100644 --- a/src/StudioCore/Project.cs +++ b/src/StudioCore/Project.cs @@ -97,7 +97,7 @@ public Project CreateRecoveryProject() } catch (Exception e) { - return this; + return null; } } }