[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

View File

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