[Settings][New+]Fixed crash when canceling template folder selection (#35060)

[New+] Fixed crash when cancel template folder selection
This commit is contained in:
Ani 2024-09-25 15:29:08 +02:00 committed by GitHub
parent 7c48f5ebd2
commit cf5addab28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -261,7 +261,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private async void PickNewTemplateFolder()
{
var newPath = await PickFolderDialog();
if (newPath.Length > 1)
if (!string.IsNullOrEmpty(newPath))
{
TemplateLocation = newPath;
}
@ -270,8 +270,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private async Task<string> PickFolderDialog()
{
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.GetSettingsWindow());
string pathFolder = await Task.FromResult<string>(ShellGetFolder.GetFolderDialogWithFlags(hwnd, ShellGetFolder.FolderDialogFlags._BIF_NEWDIALOGSTYLE));
return pathFolder;
return await Task.FromResult(GetFolderDialogWithFlags(hwnd, FolderDialogFlags._BIF_NEWDIALOGSTYLE));
}
private void SaveSettingsToJson()