diff --git a/Dalamud/Game/Framework.cs b/Dalamud/Game/Framework.cs index 808bbce50..a2b954c36 100644 --- a/Dalamud/Game/Framework.cs +++ b/Dalamud/Game/Framework.cs @@ -33,8 +33,8 @@ internal sealed class Framework : IInternalDisposableService, IFramework private readonly Stopwatch updateStopwatch = new(); private readonly HitchDetector hitchDetector; - private readonly Hook updateHook; - private readonly Hook destroyHook; + private readonly Hook? updateHook; + private readonly Hook? destroyHook; [ServiceManager.ServiceDependency] private readonly GameLifecycle lifecycle = Service.Get(); @@ -66,8 +66,8 @@ internal sealed class Framework : IInternalDisposableService, IFramework this.updateHook = Hook.FromAddress((nint)CSFramework.StaticVirtualTablePointer->Tick, this.HandleFrameworkUpdate); this.destroyHook = Hook.FromAddress((nint)CSFramework.StaticVirtualTablePointer->Destroy, this.HandleFrameworkDestroy); - this.updateHook.Enable(); - this.destroyHook.Enable(); + this.updateHook?.Enable(); + this.destroyHook?.Enable(); } /// @@ -312,14 +312,14 @@ internal sealed class Framework : IInternalDisposableService, IFramework this.RunOnFrameworkThread(() => { // ReSharper disable once AccessToDisposedClosure - this.updateHook.Disable(); + this.updateHook?.Disable(); // ReSharper disable once AccessToDisposedClosure - this.destroyHook.Disable(); + this.destroyHook?.Disable(); }).Wait(); - this.updateHook.Dispose(); - this.destroyHook.Dispose(); + this.updateHook?.Dispose(); + this.destroyHook?.Dispose(); this.updateStopwatch.Reset(); StatsStopwatch.Reset(); @@ -465,7 +465,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework this.hitchDetector.Stop(); original: - return this.updateHook.OriginalDisposeSafe(thisPtr); + return this.updateHook?.OriginalDisposeSafe(thisPtr) ?? false; } private unsafe bool HandleFrameworkDestroy(CSFramework* thisPtr)