mirror of https://github.com/OpenVPN/openvpn-gui
Replace assertions
parent
e699e94d40
commit
f93b335c9a
32
options.c
32
options.c
|
@ -37,9 +37,6 @@
|
|||
#include <combaseapi.h>
|
||||
|
||||
#include "options.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "openvpn-gui-res.h"
|
||||
#include "localization.h"
|
||||
|
@ -466,19 +463,23 @@ BrowseFolder (const WCHAR* initial_path, WCHAR* selected_path)
|
|||
|
||||
// Create dialog
|
||||
initResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
assert(SUCCEEDED(initResult));
|
||||
if (FAILED(initResult))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
result = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_ALL, &IID_IFileOpenDialog, &pfd);
|
||||
assert(SUCCEEDED(result));
|
||||
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
// Select folders, not files
|
||||
{
|
||||
DWORD dwOptions;
|
||||
result = pfd->lpVtbl->GetOptions(pfd, &dwOptions);
|
||||
assert(SUCCEEDED(result));
|
||||
if(SUCCEEDED(result))
|
||||
{
|
||||
dwOptions |= FOS_PICKFOLDERS;
|
||||
result = pfd->lpVtbl->SetOptions(pfd, dwOptions);
|
||||
assert(SUCCEEDED(result));
|
||||
}
|
||||
}
|
||||
|
||||
// Set initial path
|
||||
|
@ -499,20 +500,29 @@ BrowseFolder (const WCHAR* initial_path, WCHAR* selected_path)
|
|||
IShellItem* psi;
|
||||
LPOLESTR path = NULL;
|
||||
|
||||
assert(SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &psi)));
|
||||
|
||||
assert(SUCCEEDED(psi->lpVtbl->GetDisplayName(psi, SIGDN_FILESYSPATH, &path)));
|
||||
result = pfd->lpVtbl->GetResult(pfd, &psi);
|
||||
if(SUCCEEDED(result))
|
||||
{
|
||||
result = psi->lpVtbl->GetDisplayName(psi, SIGDN_FILESYSPATH, &path);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
wcsncpy_s(selected_path, MAX_PATH, path, MAX_PATH);
|
||||
selected_path[MAX_PATH - 1] = 0;
|
||||
|
||||
CoTaskMemFree(path);
|
||||
|
||||
psi->lpVtbl->Release(psi);
|
||||
}else
|
||||
{
|
||||
dialogResult = E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
pfd->lpVtbl->Release(pfd);
|
||||
}
|
||||
|
||||
if (initResult != RPC_E_CHANGED_MODE && SUCCEEDED(initResult))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue