Browse Source

Fixed file dialog crash

pull/261/head
Nikita Tsukanov 11 years ago
parent
commit
66aedf3d67
  1. 8
      src/Windows/Perspex.Win32/SystemDialogImpl.cs

8
src/Windows/Perspex.Win32/SystemDialogImpl.cs

@ -90,8 +90,8 @@ namespace Perspex.Win32
: UnmanagedMethods.GetSaveFileName(new IntPtr(pofn)); : UnmanagedMethods.GetSaveFileName(new IntPtr(pofn));
if (!res) if (!res)
return null; return null;
if (dialog?.Filters.Count > 0)
userSelectedExt = dialog.Filters[ofn.nFilterIndex - 1].Extensions[0]; userSelectedExt = dialog.Filters[ofn.nFilterIndex - 1].Extensions.FirstOrDefault();
} }
var cStart = 0; var cStart = 0;
string dir = null; string dir = null;
@ -117,8 +117,8 @@ namespace Perspex.Win32
if (dialog is SaveFileDialog) if (dialog is SaveFileDialog)
{ {
if (string.IsNullOrWhiteSpace(Path.GetExtension(dir)) && if (string.IsNullOrWhiteSpace(Path.GetExtension(dir)) &&
!string.IsNullOrWhiteSpace(userSelectedExt) && !string.IsNullOrWhiteSpace(userSelectedExt) &&
!userSelectedExt.Contains("*")) !userSelectedExt.Contains("*"))
dir = Path.ChangeExtension(dir, userSelectedExt); dir = Path.ChangeExtension(dir, userSelectedExt);
} }

Loading…
Cancel
Save