Skip to content

Commit

Permalink
Fix crashes when no VS dir is autodetected or manually set
Browse files Browse the repository at this point in the history
  • Loading branch information
TalkTakesTime committed Feb 12, 2022
1 parent d94132a commit 25ebbcd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
/_ReSharper.Caches/
releases/
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: ComponentFactory(typeof(VampireSurvivorsFactory))]
8 changes: 6 additions & 2 deletions UI/Components/VampireSurvivorsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ public class VampireSurvivorsComponent : ControlComponent {
Settings = new VampireSurvivorsSettings();
_control = (VampireSurvivorsControl)Control;
ResetState();

CurrentState.OnStart += state_OnStart;
CurrentState.OnReset += state_OnReset;
}

private void state_OnStart(object sender, EventArgs e) {
if (string.IsNullOrEmpty(Settings.VsInstallDir)) {
return;
}

_saveWatcher = new FileSystemWatcher(Path.Combine(Settings.VsInstallDir, SaveData.SaveDataDir));
_saveWatcher.Filter = SaveData.SaveDataFile;
_saveWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.CreationTime;
Expand All @@ -52,7 +56,7 @@ out State state
private void state_OnReset(object sender, TimerPhase _) => StopWatching();

private void StopWatching() {
_saveWatcher.Dispose();
_saveWatcher?.Dispose();
_saveWatcher = null;
ResetState();
}
Expand Down
3 changes: 2 additions & 1 deletion UI/Components/VampireSurvivorsFactory.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System;
using System.Reflection;
using LiveSplit.Model;

namespace LiveSplit.UI.Components {
public class VampireSurvivorsFactory : IComponentFactory {
public string ComponentName => "Vampire Survivors Tracker";
public string Description => "Displays achievements obtained so far in the current Vampire Survivors run.";

public Version Version => Version.Parse("0.1.0");
public Version Version => Assembly.GetExecutingAssembly().GetName().Version;
public ComponentCategory Category => ComponentCategory.Information;

public string UpdateName => ComponentName;
Expand Down
3 changes: 3 additions & 0 deletions UI/Components/VampireSurvivorsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ private void btnSelectVsDir_Click(object sender, EventArgs e) {
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
txtVsDir.Text = "";
VsInstallDir = null;
return;
}

txtVsDir.Text = vsDir;
VsInstallDir = vsDir;
}

Expand Down

0 comments on commit 25ebbcd

Please sign in to comment.