Fix compilation with MinGW on Windows
Use the explicit 'W' (wide) symbols from the Windows API to provide Unicode support regardless of whether UNICODE is defined: - SetFileAttributesW - LPCWSTR Define UNICODE anyway for the sake of thirdparty code that uses the aliases, which only work properly when UNICODE is defined: - SetFileAttributes - LPCTSTR If UNICODE is not defined then the aliases refer to the narrow symbols: - SetFileAttributesA - LPCSTR But the explict 'W' symbols are still available. The aliases are only needed for compatibility with code written prior to Windows NT.
This commit is contained in:
parent
ac413b2997
commit
e0eaf973ac
3 changed files with 7 additions and 13 deletions
|
@ -53,6 +53,9 @@ elseif(CC_IS_MINGW)
|
|||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--large-address-aware")
|
||||
endif (NOT BUILD_64)
|
||||
|
||||
add_definitions(-D_UNICODE)
|
||||
add_definitions(-DUNICODE)
|
||||
|
||||
elseif(CC_IS_CLANG)
|
||||
message(STATUS "Using Compiler CLANG ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
|
||||
|
|
|
@ -75,9 +75,9 @@ void WindowsPlatformTheme::startListening()
|
|||
return;
|
||||
}
|
||||
m_isListening = true;
|
||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, windowsThemeKey.c_str(), 0,
|
||||
KEY_NOTIFY | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE | KEY_WOW64_64KEY,
|
||||
&hKey) == ERROR_SUCCESS) {
|
||||
if (RegOpenKeyExW(HKEY_CURRENT_USER, windowsThemeKey.c_str(), 0,
|
||||
KEY_NOTIFY | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE | KEY_WOW64_64KEY,
|
||||
&hKey) == ERROR_SUCCESS) {
|
||||
m_listenThread = std::thread([this]() { th_listen(); });
|
||||
} else {
|
||||
LOGD() << "Failed opening key for listening dark theme changes.";
|
||||
|
|
|
@ -449,16 +449,7 @@ bool MasterScore::saveFile(bool generateBackup)
|
|||
dir.mkdir(backupSubdirString);
|
||||
#ifdef Q_OS_WIN
|
||||
const QString backupDirNativePath = QDir::toNativeSeparators(backupDirString);
|
||||
#if (defined (_MSCVER) || defined (_MSC_VER))
|
||||
#if (defined (UNICODE))
|
||||
SetFileAttributes((LPCTSTR)backupDirNativePath.unicode(), FILE_ATTRIBUTE_HIDDEN);
|
||||
#else
|
||||
// Use byte-based Windows function
|
||||
SetFileAttributes((LPCTSTR)backupDirNativePath.toLocal8Bit(), FILE_ATTRIBUTE_HIDDEN);
|
||||
#endif
|
||||
#else
|
||||
SetFileAttributes((LPCTSTR)backupDirNativePath.toLocal8Bit(), FILE_ATTRIBUTE_HIDDEN);
|
||||
#endif
|
||||
SetFileAttributesW(reinterpret_cast<LPCWSTR>(backupDirNativePath.utf16()), FILE_ATTRIBUTE_HIDDEN);
|
||||
#endif
|
||||
}
|
||||
const QString backupName = QString(".") + info.fileName() + QString(",");
|
||||
|
|
Loading…
Reference in a new issue