From 2e4d2dff032991015be04695bb0ef8542db7008e Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 6 Aug 2018 12:29:43 +0200 Subject: [PATCH] fix possible UNICODE related build failure due to OCCT cmake flags --- src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp | 6 +++--- src/3rdParty/salomesmesh/src/SMESH/SMESH_Gen.cpp | 2 +- src/App/Application.cpp | 4 ++-- src/Gui/GuiConsole.cpp | 2 +- src/Main/MainGui.cpp | 9 +++++---- src/Mod/Sandbox/Gui/Command.cpp | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp b/src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp index fd3daf555c..43d567298c 100644 --- a/src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp +++ b/src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp @@ -79,8 +79,8 @@ bool SMESH_File::open() if ( !_map && length > 0 ) { #ifdef WIN32 - _file = CreateFile(_name.data(), GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + _file = CreateFileA(_name.data(), GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); bool ok = ( _file != INVALID_HANDLE_VALUE ); #else _file = ::open(_name.data(), O_RDONLY ); @@ -292,7 +292,7 @@ bool SMESH_File::openForWriting() { #ifdef WIN32 - _file = CreateFile( _name.c_str(), // name of the write + _file = CreateFileA(_name.c_str(), // name of the write GENERIC_WRITE, // open for writing 0, // do not share NULL, // default security diff --git a/src/3rdParty/salomesmesh/src/SMESH/SMESH_Gen.cpp b/src/3rdParty/salomesmesh/src/SMESH/SMESH_Gen.cpp index f7cb1dc240..3ec005dd3c 100644 --- a/src/3rdParty/salomesmesh/src/SMESH/SMESH_Gen.cpp +++ b/src/3rdParty/salomesmesh/src/SMESH/SMESH_Gen.cpp @@ -1037,7 +1037,7 @@ std::vector< std::string > SMESH_Gen::GetPluginXMLPaths() xmlPath += sep + plugin + ".xml"; bool fileOK; #ifdef WIN32 - fileOK = (GetFileAttributes(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES); + fileOK = (GetFileAttributesA(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES); #else fileOK = (access(xmlPath.c_str(), F_OK) == 0); #endif diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 6327190aca..30205feba2 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -2270,7 +2270,7 @@ void Application::ExtractUserPath() #elif defined(FC_OS_WIN32) WCHAR szPath[MAX_PATH]; - TCHAR dest[MAX_PATH*3]; + char dest[MAX_PATH*3]; // Get the default path where we can save our documents. It seems that // 'CSIDL_MYDOCUMENTS' doesn't work on all machines, so we use 'CSIDL_PERSONAL' // which does the same. @@ -2454,7 +2454,7 @@ std::string Application::FindHomePath(const char* sCall) // Python interpreter is already initialized. wchar_t szFileName [MAX_PATH]; if (Py_IsInitialized()) { - GetModuleFileNameW(GetModuleHandle(sCall),szFileName, MAX_PATH-1); + GetModuleFileNameW(GetModuleHandleA(sCall),szFileName, MAX_PATH-1); } else { GetModuleFileNameW(0, szFileName, MAX_PATH-1); diff --git a/src/Gui/GuiConsole.cpp b/src/Gui/GuiConsole.cpp index 2987f93963..70c7c6ec9f 100644 --- a/src/Gui/GuiConsole.cpp +++ b/src/Gui/GuiConsole.cpp @@ -62,7 +62,7 @@ GUIConsole::GUIConsole (void) ::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE),&csbi); csbi.dwSize.Y = s_nMaxLines; ::SetConsoleScreenBufferSize(::GetStdHandle(STD_OUTPUT_HANDLE),csbi.dwSize); - ::SetConsoleTitle( "FreeCAD Console"); + ::SetConsoleTitleA( "FreeCAD Console"); *stdout = *::_fdopen(::_open_osfhandle(reinterpret_cast(::GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT), "w"); ::setvbuf(stdout, 0, _IONBF, 0); diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp index 5d0557e115..e218e7b6be 100644 --- a/src/Main/MainGui.cpp +++ b/src/Main/MainGui.cpp @@ -336,7 +336,7 @@ typedef BOOL (__stdcall *tMDWD)( static tMDWD s_pMDWD; static HMODULE s_hDbgHelpMod; static MINIDUMP_TYPE s_dumpTyp = MiniDumpNormal; -static std::string s_szMiniDumpFileName; // initialize with whatever appropriate... +static std::wstring s_szMiniDumpFileName; // initialize with whatever appropriate... #include class MyStackWalker : public StackWalker @@ -380,7 +380,7 @@ static LONG __stdcall MyCrashHandlerExceptionFilter(EXCEPTION_POINTERS* pEx) bool bFailed = true; HANDLE hFile; - hFile = CreateFile(s_szMiniDumpFileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileW(s_szMiniDumpFileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { MINIDUMP_EXCEPTION_INFORMATION stMDEI; @@ -423,11 +423,12 @@ void InitMiniDumpWriter(const std::string& filename) { if (s_hDbgHelpMod != NULL) return; - s_szMiniDumpFileName = filename; + Base::FileInfo fi(filename); + s_szMiniDumpFileName = fi.toStdWString(); // Initialize the member, so we do not load the dll after the exception has occurred // which might be not possible anymore... - s_hDbgHelpMod = LoadLibrary(("dbghelp.dll")); + s_hDbgHelpMod = LoadLibraryA(("dbghelp.dll")); if (s_hDbgHelpMod != NULL) s_pMDWD = (tMDWD) GetProcAddress(s_hDbgHelpMod, "MiniDumpWriteDump"); diff --git a/src/Mod/Sandbox/Gui/Command.cpp b/src/Mod/Sandbox/Gui/Command.cpp index b4f30eb304..50ee3878d7 100644 --- a/src/Mod/Sandbox/Gui/Command.cpp +++ b/src/Mod/Sandbox/Gui/Command.cpp @@ -1047,7 +1047,7 @@ protected: SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW)); Rectangle(hdc, 0, 0, width(), height()); RECT rect = {0, 0, width(), height() }; - DrawText(hdc, "Hello World!", 12, &rect, + DrawTextA(hdc, "Hello World!", 12, &rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER); #if QT_VERSION < 0x050000 releaseDC(hdc);