From bb1b84f54947729ba25e1ea0f15936e7eb4bf0c7 Mon Sep 17 00:00:00 2001 From: Mark Downie Date: Sun, 31 Jan 2016 18:12:13 -0500 Subject: [PATCH] Updated to avoid invalid cast exception thrown. --- .../PostEditorPreferencesPanel.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/managed/OpenLiveWriter.PostEditor/PostEditorPreferencesPanel.cs b/src/managed/OpenLiveWriter.PostEditor/PostEditorPreferencesPanel.cs index 50bc69ce..3c02ff35 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostEditorPreferencesPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostEditorPreferencesPanel.cs @@ -176,9 +176,15 @@ namespace OpenLiveWriter.PostEditor MovePosts(Path.Combine(_originalFolder + @"\\Drafts\\"), destinationDrafts); - PostEditorForm frm = (PostEditorForm)Application.OpenForms?[0]; - PostEditorMainControl ctrl = (PostEditorMainControl)frm?.Controls?[0]; - ctrl?.FirePostListChangedEvent(); + PostEditorForm frm = Application.OpenForms?[0] as PostEditorForm; + if (frm != null) + { + PostEditorMainControl ctrl = frm.Controls?[0] as PostEditorMainControl; + if (ctrl != null) + { + ctrl.FirePostListChangedEvent(); + } + } } _postEditorPreferences.Changed();