From 66aedf3d67fdecd28fc7d8a98dfac5f36e3af0dc Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 7 Oct 2015 11:50:10 +0300 Subject: [PATCH] Fixed file dialog crash --- src/Windows/Perspex.Win32/SystemDialogImpl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Windows/Perspex.Win32/SystemDialogImpl.cs b/src/Windows/Perspex.Win32/SystemDialogImpl.cs index f237665299..69f394c75c 100644 --- a/src/Windows/Perspex.Win32/SystemDialogImpl.cs +++ b/src/Windows/Perspex.Win32/SystemDialogImpl.cs @@ -90,8 +90,8 @@ namespace Perspex.Win32 : UnmanagedMethods.GetSaveFileName(new IntPtr(pofn)); if (!res) return null; - - userSelectedExt = dialog.Filters[ofn.nFilterIndex - 1].Extensions[0]; + if (dialog?.Filters.Count > 0) + userSelectedExt = dialog.Filters[ofn.nFilterIndex - 1].Extensions.FirstOrDefault(); } var cStart = 0; string dir = null; @@ -117,8 +117,8 @@ namespace Perspex.Win32 if (dialog is SaveFileDialog) { if (string.IsNullOrWhiteSpace(Path.GetExtension(dir)) && - !string.IsNullOrWhiteSpace(userSelectedExt) && - !userSelectedExt.Contains("*")) + !string.IsNullOrWhiteSpace(userSelectedExt) && + !userSelectedExt.Contains("*")) dir = Path.ChangeExtension(dir, userSelectedExt); }