Merge pull request #361 from SirCxyrtyx/startup-crash

Exit gracefully if no game is selected during first-time setup
This commit is contained in:
Valentin 2023-02-22 10:10:38 +01:00 committed by GitHub
commit 5d730f0bc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,6 +73,12 @@ public class ApplicationViewModel : ViewModel
LoadingModes = new LoadingModesViewModel();
AvoidEmptyGameDirectoryAndSetEGame(false);
if (UserSettings.Default.GameDirectory is null)
{
//If no game is selected, many things will break before a shutdown request is processed in the normal way.
//A hard exit is preferable to an unhandled expection in this case
Environment.Exit(0);
}
CUE4Parse = new CUE4ParseViewModel(UserSettings.Default.GameDirectory);
CustomDirectories = new CustomDirectoriesViewModel(CUE4Parse.Game, UserSettings.Default.GameDirectory);
SettingsView = new SettingsViewModel(CUE4Parse.Game);