Skip to content

Commit

Permalink
Fixed first start crash
Browse files Browse the repository at this point in the history
Crash was caused on first program start because settings file was checked before created.
  • Loading branch information
Epenko1337 committed Feb 11, 2023
1 parent 6ef80e4 commit 2444bd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions epexgui/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static class Global
public static string ConfigsFolder = MainFolder + "\\Configs";
public static string SettingsFile = MainFolder + "\\Settings.txt";
public static string WireSock = string.Empty;
public static SettingsManager setMan = new SettingsManager();
public static SettingsManager setMan;
}
internal static class Program
{
Expand All @@ -26,6 +26,10 @@ static void Main()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

if (!Directory.Exists(Global.MainFolder)) Directory.CreateDirectory(Global.MainFolder);
if (!Directory.Exists(Global.ConfigsFolder)) Directory.CreateDirectory(Global.ConfigsFolder);
Global.setMan = new SettingsManager();

if (!IsWiresockInstalled())
{
MessageBox.Show("Wiresock will be installed now", "Wiresock not found", MessageBoxButtons.OK, MessageBoxIcon.Information);
Expand All @@ -37,8 +41,6 @@ static void Main()
}
MessageBox.Show("Wiresock successfully installed", "Installation complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
if (!Directory.Exists(Global.MainFolder)) Directory.CreateDirectory(Global.MainFolder);
if (!Directory.Exists(Global.ConfigsFolder)) Directory.CreateDirectory(Global.ConfigsFolder);

if (Global.setMan.settings.Autorun) Global.setMan.CheckTask();
Application.Run(new Main());
Expand Down
1 change: 1 addition & 0 deletions epexgui/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public struct Settings
private IniData data;
public SettingsManager()
{
if (!File.Exists(Global.SettingsFile)) CreateSettings();
InitSettings();
parser = new FileIniDataParser();
data = parser.ReadFile(Global.SettingsFile);
Expand Down

0 comments on commit 2444bd5

Please sign in to comment.