Browse Source
Merge pull request #7569 from MarchingCube/win32-filepicker-no-exceptions
Avoid using COM exceptions for dialog control flow.
pull/7576/head
Dariusz Komosiński
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
22 additions and
11 deletions
-
src/Windows/Avalonia.Win32/SystemDialogImpl.cs
-
src/Windows/Avalonia.Win32/Win32Com/win32.idl
|
|
|
@ -89,7 +89,16 @@ namespace Avalonia.Win32 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
frm.Show(hWnd); |
|
|
|
var showResult = frm.Show(hWnd); |
|
|
|
|
|
|
|
if ((uint)showResult == (uint)UnmanagedMethods.HRESULT.E_CANCELLED) |
|
|
|
{ |
|
|
|
return result; |
|
|
|
} |
|
|
|
else if ((uint)showResult != (uint)UnmanagedMethods.HRESULT.S_OK) |
|
|
|
{ |
|
|
|
throw new Win32Exception(showResult); |
|
|
|
} |
|
|
|
|
|
|
|
if (openDialog?.AllowMultiple == true) |
|
|
|
{ |
|
|
|
@ -118,10 +127,6 @@ namespace Avalonia.Win32 |
|
|
|
} |
|
|
|
catch (COMException ex) |
|
|
|
{ |
|
|
|
if ((uint)ex.HResult == (uint)UnmanagedMethods.HRESULT.E_CANCELLED) |
|
|
|
{ |
|
|
|
return result; |
|
|
|
} |
|
|
|
throw new Win32Exception(ex.HResult); |
|
|
|
} |
|
|
|
})!; |
|
|
|
@ -161,7 +166,17 @@ namespace Avalonia.Win32 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
frm.Show(hWnd); |
|
|
|
var showResult = frm.Show(hWnd); |
|
|
|
|
|
|
|
if ((uint)showResult == (uint)UnmanagedMethods.HRESULT.E_CANCELLED) |
|
|
|
{ |
|
|
|
return result; |
|
|
|
} |
|
|
|
else if ((uint)showResult != (uint)UnmanagedMethods.HRESULT.S_OK) |
|
|
|
{ |
|
|
|
throw new Win32Exception(showResult); |
|
|
|
} |
|
|
|
|
|
|
|
if (frm.Result is not null) |
|
|
|
{ |
|
|
|
result = GetAbsoluteFilePath(frm.Result); |
|
|
|
@ -171,10 +186,6 @@ namespace Avalonia.Win32 |
|
|
|
} |
|
|
|
catch (COMException ex) |
|
|
|
{ |
|
|
|
if ((uint)ex.HResult == (uint)UnmanagedMethods.HRESULT.E_CANCELLED) |
|
|
|
{ |
|
|
|
return result; |
|
|
|
} |
|
|
|
throw new Win32Exception(ex.HResult); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
@ -112,7 +112,7 @@ interface IShellItemArray : IUnknown |
|
|
|
interface IModalWindow : IUnknown |
|
|
|
{ |
|
|
|
[local] |
|
|
|
HRESULT Show( |
|
|
|
int Show( |
|
|
|
[in, unique] HWND hwndOwner); |
|
|
|
} |
|
|
|
|
|
|
|
|