Skip to content

Commit

Permalink
Fix exception at startup w/o default game inst
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Jul 21, 2023
1 parent 1748b7d commit d219020
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 8 additions & 7 deletions GUI/Main/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,6 @@ protected override void OnShown(EventArgs e)
} while (CurrentInstance == null);
// We can only reach this point if CurrentInstance is not null
// AND we acquired the lock for it successfully
if (!configuration.CheckForUpdatesOnLaunchNoNag && AutoUpdate.CanUpdate)
{
log.Debug("Asking user if they wish for auto-updates");
if (new AskUserForAutoUpdatesDialog().ShowDialog(this) == DialogResult.OK)
configuration.CheckForUpdatesOnLaunch = true;
configuration.CheckForUpdatesOnLaunchNoNag = true;
}
evt.Result = true;
},
(sender, evt) =>
Expand Down Expand Up @@ -390,6 +383,14 @@ private void CurrentInstanceUpdated(bool allowRepoUpdate)
Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml"),
CurrentInstance.game);

if (!configuration.CheckForUpdatesOnLaunchNoNag && AutoUpdate.CanUpdate)
{
log.Debug("Asking user if they wish for auto-updates");
if (new AskUserForAutoUpdatesDialog().ShowDialog(this) == DialogResult.OK)
configuration.CheckForUpdatesOnLaunch = true;
configuration.CheckForUpdatesOnLaunchNoNag = true;
}

var pluginsPath = Path.Combine(CurrentInstance.CkanDir(), "Plugins");
if (!Directory.Exists(pluginsPath))
Directory.CreateDirectory(pluginsPath);
Expand Down
5 changes: 4 additions & 1 deletion GUI/Model/GUIConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ public Point WindowLoc

public void Save()
{
SaveConfiguration(this);
if (!string.IsNullOrEmpty(path))
{
SaveConfiguration(this);
}
}

public static GUIConfiguration LoadOrCreateConfiguration(string path, IGame game)
Expand Down

0 comments on commit d219020

Please sign in to comment.