From 95dde6183a4d38d8fdfc7946920c1bed99461077 Mon Sep 17 00:00:00 2001 From: Khang Yeen Lee Date: Wed, 22 Jul 2015 13:31:43 +0200 Subject: [PATCH] #16. Fixed a null pointer crash. --- .../UI/Controls/NotificationSettingsControl.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/HudsonTrayTracker/UI/Controls/NotificationSettingsControl.cs b/HudsonTrayTracker/UI/Controls/NotificationSettingsControl.cs index 451a028..ad9bcfb 100644 --- a/HudsonTrayTracker/UI/Controls/NotificationSettingsControl.cs +++ b/HudsonTrayTracker/UI/Controls/NotificationSettingsControl.cs @@ -42,7 +42,10 @@ protected override void OnLoad(EventArgs e) if (DesignMode || Process.GetCurrentProcess().ProcessName == "devenv") return; - configurationService = (ConfigurationService)ContextRegistry.GetContext().GetObject("ConfigurationService"); + if (configurationService == null) + { + configurationService = (ConfigurationService)ContextRegistry.GetContext().GetObject("ConfigurationService"); + } statusLabel.Text = HudsonTrayTrackerResources.ResourceManager.GetString("NotificationSettings_" + Status); SoundPath = configurationService.GetSoundPath(Status); @@ -71,6 +74,11 @@ private void ChooseFile() private void SetPath(string path) { + if (configurationService == null) + { + configurationService = (ConfigurationService)ContextRegistry.GetContext().GetObject("ConfigurationService"); + } + configurationService.SetSoundPath(Status, path); SoundPath = path; }