Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit b680235

Browse files
authored
Merge pull request #549 from ficristo/VS2015-fix-warnings
VS2015: fix some warnings
2 parents 15c0f8e + 419991c commit b680235

5 files changed

Lines changed: 48 additions & 75 deletions

File tree

appshell/appshell_extensions_win.cpp

Lines changed: 26 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -422,66 +422,35 @@ int32 ShowOpenDialog(bool allowMultipleSelection,
422422
ConvertToNativePath(initialDirectory);
423423

424424
if (chooseDirectory) {
425-
// check current OS version
426-
OSVERSIONINFO osvi;
427-
memset(&osvi, 0, sizeof(OSVERSIONINFO));
428-
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
429-
if (GetVersionEx(&osvi) && (osvi.dwMajorVersion >= 6)) {
430-
// for Vista or later, use the MSDN-preferred implementation of the Open File dialog in pick folders mode
431-
IFileDialog *pfd;
432-
if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd)))) {
433-
// configure the dialog to Select Folders only
434-
DWORD dwOptions;
435-
if (SUCCEEDED(pfd->GetOptions(&dwOptions))) {
436-
pfd->SetOptions(dwOptions | FOS_PICKFOLDERS | FOS_DONTADDTORECENT);
437-
IShellItem *shellItem = NULL;
438-
if (SUCCEEDED(SHCreateItemFromParsingName(initialDirectory.c_str(), 0, IID_IShellItem, reinterpret_cast<void**>(&shellItem))))
439-
pfd->SetFolder(shellItem);
440-
pfd->SetTitle(title.c_str());
441-
if (SUCCEEDED(pfd->Show(GetActiveWindow()))) {
442-
IShellItem *psi;
443-
if (SUCCEEDED(pfd->GetResult(&psi))) {
444-
LPWSTR lpwszName = NULL;
445-
if(SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, (LPWSTR*)&lpwszName))) {
446-
// Add directory path to the result
447-
std::wstring wstrName(lpwszName);
448-
ExtensionString pathName(wstrName);
449-
ConvertToUnixPath(pathName);
450-
selectedFiles->SetString(0, pathName);
451-
::CoTaskMemFree(lpwszName);
452-
}
453-
psi->Release();
425+
IFileDialog *pfd;
426+
if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd)))) {
427+
// configure the dialog to Select Folders only
428+
DWORD dwOptions;
429+
if (SUCCEEDED(pfd->GetOptions(&dwOptions))) {
430+
pfd->SetOptions(dwOptions | FOS_PICKFOLDERS | FOS_DONTADDTORECENT);
431+
IShellItem *shellItem = NULL;
432+
if (SUCCEEDED(SHCreateItemFromParsingName(initialDirectory.c_str(), 0, IID_IShellItem, reinterpret_cast<void**>(&shellItem))))
433+
pfd->SetFolder(shellItem);
434+
pfd->SetTitle(title.c_str());
435+
if (SUCCEEDED(pfd->Show(GetActiveWindow()))) {
436+
IShellItem *psi;
437+
if (SUCCEEDED(pfd->GetResult(&psi))) {
438+
LPWSTR lpwszName = NULL;
439+
if(SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, (LPWSTR*)&lpwszName))) {
440+
// Add directory path to the result
441+
std::wstring wstrName(lpwszName);
442+
ExtensionString pathName(wstrName);
443+
ConvertToUnixPath(pathName);
444+
selectedFiles->SetString(0, pathName);
445+
::CoTaskMemFree(lpwszName);
454446
}
447+
psi->Release();
455448
}
456-
if (shellItem != NULL)
457-
shellItem->Release();
458-
}
459-
pfd->Release();
460-
}
461-
} else {
462-
// for XP, use the old-styled SHBrowseForFolder() implementation
463-
BROWSEINFO bi = {0};
464-
bi.hwndOwner = GetActiveWindow();
465-
bi.lpszTitle = title.c_str();
466-
bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
467-
bi.lpfn = SetInitialPathCallback;
468-
bi.lParam = (LPARAM)initialDirectory.c_str();
469-
470-
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
471-
if (pidl != 0) {
472-
if (SHGetPathFromIDList(pidl, szFile)) {
473-
// Add directory path to the result
474-
ExtensionString pathName(szFile);
475-
ConvertToUnixPath(pathName);
476-
selectedFiles->SetString(0, pathName);
477-
}
478-
IMalloc* pMalloc = NULL;
479-
SHGetMalloc(&pMalloc);
480-
if (pMalloc) {
481-
pMalloc->Free(pidl);
482-
pMalloc->Release();
483449
}
450+
if (shellItem != NULL)
451+
shellItem->Release();
484452
}
453+
pfd->Release();
485454
}
486455
} else {
487456
OPENFILENAME ofn;
@@ -729,7 +698,7 @@ int32 GetFileInfo(ExtensionString filename, uint32& modtime, bool& isDir, double
729698

730699
const int BOMLength = 3;
731700

732-
typedef enum CheckedState { CS_UNKNOWN, CS_NO, CS_YES };
701+
enum CheckedState { CS_UNKNOWN, CS_NO, CS_YES };
733702

734703
typedef struct UTFValidationState {
735704

appshell/appshell_node_process_win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ DWORD WINAPI NodeThread(LPVOID lpParam) {
224224
hNodeReadThread = CreateThread(NULL, 0, NodeReadThread, NULL, 0, NULL);
225225

226226
// Loop to check if process is still running
227-
BOOL bSuccess = FALSE;
227+
bSuccess = FALSE;
228228
DWORD exitCode = 0;
229229
for (;;)
230230
{

appshell/cef_dark_aero_window.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,12 @@ HINSTANCE CDwmDLL::LoadLibrary()
5454
{
5555
if (mhDwmDll == NULL)
5656
{
57-
// dynamically load dwmapi.dll if running Windows Vista or later (ie. not on XP)
58-
::OSVERSIONINFO osvi = {0};
59-
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
60-
::GetVersionEx(&osvi);
61-
if ((osvi.dwMajorVersion > 5) || ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion >= 1) ))
57+
mhDwmDll = ::LoadLibrary(TEXT("dwmapi.dll"));
58+
if (mhDwmDll != NULL)
6259
{
63-
mhDwmDll = ::LoadLibrary(TEXT("dwmapi.dll"));
64-
if (mhDwmDll != NULL)
65-
{
66-
pfnDwmExtendFrameIntoClientArea = (PFNDWMEFICA)::GetProcAddress(mhDwmDll, "DwmExtendFrameIntoClientArea");
67-
pfnDwmDefWindowProc = (PFNDWMDWP)::GetProcAddress(mhDwmDll, "DwmDefWindowProc");
68-
pfnDwmIsCompositionEnabled = (PFNDWMICE)::GetProcAddress(mhDwmDll, "DwmIsCompositionEnabled");
69-
}
60+
pfnDwmExtendFrameIntoClientArea = (PFNDWMEFICA)::GetProcAddress(mhDwmDll, "DwmExtendFrameIntoClientArea");
61+
pfnDwmDefWindowProc = (PFNDWMDWP)::GetProcAddress(mhDwmDll, "DwmDefWindowProc");
62+
pfnDwmIsCompositionEnabled = (PFNDWMICE)::GetProcAddress(mhDwmDll, "DwmIsCompositionEnabled");
7063
}
7164
}
7265
return mhDwmDll;

appshell/cef_dark_window.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,24 @@
2323
#include "resource.h"
2424
#include <minmax.h>
2525
#include <objidl.h>
26-
#include <GdiPlus.h>
2726
#include <Uxtheme.h>
2827
#include <Shlwapi.h>
2928

3029
#define OS_WIN
3130
#include "config.h"
3231

32+
// With VS2015 including the gdiplus.h header results in many C4458 warnings.
33+
// Disable them.
34+
#ifdef _MSC_VER
35+
#pragma warning(push)
36+
#pragma warning(disable:4458) // declaration of 'xxx' hides class member
37+
#endif
38+
#include <GdiPlus.h>
39+
#ifdef _MSC_VER
40+
#pragma warning(pop)
41+
#endif
42+
43+
3344
//win HiDPI - Macro for loading button resources for scale factors start
3445
#define BUTTON_RESOURCES(scale)\
3546
if (mSysCloseButton == NULL) {\

appshell/client_app.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ void SetListValue(CefRefPtr<CefV8Value> list, int index,
9292
CefValueType type = value->GetType(index);
9393
switch (type) {
9494
case VTYPE_LIST: {
95-
CefRefPtr<CefListValue> list = value->GetList(index);
96-
new_value = CefV8Value::CreateArray(list->GetSize());
97-
SetList(list, new_value);
95+
CefRefPtr<CefListValue> listValue = value->GetList(index);
96+
new_value = CefV8Value::CreateArray(listValue->GetSize());
97+
SetList(listValue, new_value);
9898
} break;
9999
case VTYPE_BOOL:
100100
new_value = CefV8Value::CreateBool(value->GetBool(index));
@@ -347,7 +347,7 @@ bool ClientApp::OnProcessMessageReceived(
347347
CefRefPtr<CefListValue> messageArgs = message->GetArgumentList();
348348
CefString commandName = messageArgs->GetString(0);
349349
int messageId = messageArgs->GetSize() > 1 ? messageArgs->GetInt(1) : -1;
350-
bool handled = false;
350+
handled = false;
351351

352352
StContextScope ctx(browser->GetMainFrame()->GetV8Context());
353353

0 commit comments

Comments
 (0)