From f1199940b785420673797b755f59ace748535df4 Mon Sep 17 00:00:00 2001 From: Matthew Olivo Date: Sun, 29 Sep 2024 16:37:20 -0700 Subject: [PATCH] System.NullReferenceException: Object reference not set to an instance of an object. at MixItUp.Base.Util.ResetTrackerViewModel..ctor(ResetTracker model) at MixItUp.Base.ViewModel.Overlay.OverlayGoalV3ViewModel..ctor(OverlayGoalV3Model item) at MixItUp.Base.ViewModel.Overlay.OverlayWidgetV3ViewModel..ctor(OverlayWidgetV3Model widget) at MixItUp.WPF.Windows.Overlay.OverlayWidgetV3EditorWindow..ctor(OverlayWidgetV3Model item) in S:\Code\mixer-mixitup\MixItUp.WPF\Windows\Overlay\OverlayWidgetV3EditorWindow.xaml.cs:line 33 at MixItUp.WPF.Controls.MainControls.OverlayWidgetsControl.EditButton_Click(Object sender, RoutedEventArgs e) in S:\Code\mixer-mixitup\MixItUp.WPF\Controls\MainControls\OverlayWidgetsControl.xaml.cs:line 75 --- MixItUp.Base/Model/Overlay/OverlayGoalV3Model.cs | 5 +++++ MixItUp.Base/Util/ResetTracker.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/MixItUp.Base/Model/Overlay/OverlayGoalV3Model.cs b/MixItUp.Base/Model/Overlay/OverlayGoalV3Model.cs index eda2799ea..8becc14d0 100644 --- a/MixItUp.Base/Model/Overlay/OverlayGoalV3Model.cs +++ b/MixItUp.Base/Model/Overlay/OverlayGoalV3Model.cs @@ -188,6 +188,11 @@ public override async Task Initialize() { await base.Initialize(); + if (this.ResetTracker == null) + { + this.ResetTracker = new ResetTracker(); + } + CounterModel.OnCounterUpdated -= CounterModel_OnCounterUpdated; if (this.GoalType == OverlayGoalV3Type.Counter && ChannelSession.Settings.Counters.TryGetValue(this.CounterName, out CounterModel counter)) { diff --git a/MixItUp.Base/Util/ResetTracker.cs b/MixItUp.Base/Util/ResetTracker.cs index ad8b12d08..10304566d 100644 --- a/MixItUp.Base/Util/ResetTracker.cs +++ b/MixItUp.Base/Util/ResetTracker.cs @@ -115,7 +115,7 @@ public ResetTrackerViewModel() public ResetTrackerViewModel(ResetTracker model) { - this.Model = model; + this.Model = model ?? new ResetTracker(); this.Model.UpgradeToNewerFormat(); }