Windows code: Fix clang-tidy warnings about C-style casts
Replace by reinterpret_cast or const_cast, respectively. Use auto when initializing a variable to fix Clang warnings about repeating the type name, do minor tidying along the way, and a few conversions of 0 or NULL to nullptr. Change-Id: Ieb271a87ddcf064f536e1ff05d23b1e688b1b56a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
f9431f5632
commit
64e6441d9c
@ -103,7 +103,7 @@ static inline OSVERSIONINFOEX determineWinOsVersion()
|
||||
|
||||
// GetVersionEx() has been deprecated in Windows 8.1 and will return
|
||||
// only Windows 8 from that version on, so use the kernel API function.
|
||||
pRtlGetVersion((LPOSVERSIONINFO) &result); // always returns STATUS_SUCCESS
|
||||
pRtlGetVersion(reinterpret_cast<LPOSVERSIONINFO>(&result)); // always returns STATUS_SUCCESS
|
||||
#else // !Q_OS_WINCE
|
||||
GetVersionEx(&result);
|
||||
#endif
|
||||
|
@ -935,7 +935,7 @@ static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData &
|
||||
bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data,
|
||||
QFileSystemMetaData::MetaDataFlags what)
|
||||
{
|
||||
HANDLE fHandle = (HANDLE)_get_osfhandle(fd);
|
||||
auto fHandle = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
|
||||
if (fHandle != INVALID_HANDLE_VALUE) {
|
||||
return fillMetaData(fHandle, data, what);
|
||||
}
|
||||
@ -1014,7 +1014,8 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
|
||||
WIN32_FIND_DATA findData;
|
||||
// The memory structure for WIN32_FIND_DATA is same as WIN32_FILE_ATTRIBUTE_DATA
|
||||
// for all members used by fillFindData().
|
||||
bool ok = ::GetFileAttributesEx((wchar_t*)fname.nativeFilePath().utf16(), GetFileExInfoStandard,
|
||||
bool ok = ::GetFileAttributesEx(reinterpret_cast<const wchar_t*>(fname.nativeFilePath().utf16()),
|
||||
GetFileExInfoStandard,
|
||||
reinterpret_cast<WIN32_FILE_ATTRIBUTE_DATA *>(&findData));
|
||||
if (ok) {
|
||||
data.fillFromFindData(findData, false, fname.isDriveRoot());
|
||||
@ -1069,19 +1070,22 @@ static bool isDirPath(const QString &dirPath, bool *existed)
|
||||
if (path.length() == 2 && path.at(1) == QLatin1Char(':'))
|
||||
path += QLatin1Char('\\');
|
||||
|
||||
const QString longPath = QFSFileEnginePrivate::longFileName(path);
|
||||
#ifndef Q_OS_WINRT
|
||||
DWORD fileAttrib = ::GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16());
|
||||
DWORD fileAttrib = ::GetFileAttributes(reinterpret_cast<const wchar_t*>(longPath.utf16()));
|
||||
#else // Q_OS_WINRT
|
||||
DWORD fileAttrib = INVALID_FILE_ATTRIBUTES;
|
||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
||||
if (::GetFileAttributesEx((const wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), GetFileExInfoStandard, &data))
|
||||
if (::GetFileAttributesEx(reinterpret_cast<const wchar_t*>(longPath.utf16()),
|
||||
GetFileExInfoStandard, &data)) {
|
||||
fileAttrib = data.dwFileAttributes;
|
||||
}
|
||||
#endif // Q_OS_WINRT
|
||||
if (fileAttrib == INVALID_FILE_ATTRIBUTES) {
|
||||
int errorCode = GetLastError();
|
||||
if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
|
||||
WIN32_FIND_DATA findData;
|
||||
if (getFindData(QFSFileEnginePrivate::longFileName(path), findData))
|
||||
if (getFindData(longPath, findData))
|
||||
fileAttrib = findData.dwFileAttributes;
|
||||
}
|
||||
}
|
||||
@ -1411,7 +1415,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per
|
||||
if (mode == 0) // not supported
|
||||
return false;
|
||||
|
||||
bool ret = (::_wchmod((wchar_t*)entry.nativeFilePath().utf16(), mode) == 0);
|
||||
bool ret = ::_wchmod(reinterpret_cast<const wchar_t*>(entry.nativeFilePath().utf16()), mode) == 0;
|
||||
if(!ret)
|
||||
error = QSystemError(errno, QSystemError::StandardLibraryError);
|
||||
return ret;
|
||||
|
@ -515,7 +515,7 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa
|
||||
case REG_SZ: {
|
||||
QString s;
|
||||
if (dataSize) {
|
||||
s = QString::fromWCharArray(((const wchar_t *)data.constData()));
|
||||
s = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData()));
|
||||
}
|
||||
if (value != 0)
|
||||
*value = stringToVariant(s);
|
||||
@ -527,7 +527,7 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa
|
||||
if (dataSize) {
|
||||
int i = 0;
|
||||
for (;;) {
|
||||
QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i);
|
||||
QString s = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData()) + i);
|
||||
i += s.length() + 1;
|
||||
|
||||
if (s.isEmpty())
|
||||
@ -544,7 +544,7 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa
|
||||
case REG_BINARY: {
|
||||
QString s;
|
||||
if (dataSize) {
|
||||
s = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2);
|
||||
s = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData()), data.size() / 2);
|
||||
}
|
||||
if (value != 0)
|
||||
*value = stringToVariant(s);
|
||||
@ -555,7 +555,7 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa
|
||||
case REG_DWORD: {
|
||||
Q_ASSERT(data.size() == sizeof(int));
|
||||
int i;
|
||||
memcpy((char*)&i, data.constData(), sizeof(int));
|
||||
memcpy(reinterpret_cast<char*>(&i), data.constData(), sizeof(int));
|
||||
if (value != 0)
|
||||
*value = i;
|
||||
break;
|
||||
@ -564,7 +564,7 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa
|
||||
case REG_QWORD: {
|
||||
Q_ASSERT(data.size() == sizeof(qint64));
|
||||
qint64 i;
|
||||
memcpy((char*)&i, data.constData(), sizeof(qint64));
|
||||
memcpy(reinterpret_cast<char*>(&i), data.constData(), sizeof(qint64));
|
||||
if (value != 0)
|
||||
*value = i;
|
||||
break;
|
||||
@ -688,12 +688,12 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
|
||||
|
||||
if (type == REG_BINARY) {
|
||||
QString s = variantToString(value);
|
||||
regValueBuff = QByteArray((const char*)s.utf16(), s.length() * 2);
|
||||
regValueBuff = QByteArray(reinterpret_cast<const char*>(s.utf16()), s.length() * 2);
|
||||
} else {
|
||||
QStringList::const_iterator it = l.constBegin();
|
||||
for (; it != l.constEnd(); ++it) {
|
||||
const QString &s = *it;
|
||||
regValueBuff += QByteArray((const char*)s.utf16(), (s.length() + 1) * 2);
|
||||
regValueBuff += QByteArray(reinterpret_cast<const char*>(s.utf16()), (s.length() + 1) * 2);
|
||||
}
|
||||
regValueBuff.append((char)0);
|
||||
regValueBuff.append((char)0);
|
||||
@ -705,7 +705,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
|
||||
case QVariant::UInt: {
|
||||
type = REG_DWORD;
|
||||
qint32 i = value.toInt();
|
||||
regValueBuff = QByteArray((const char*)&i, sizeof(qint32));
|
||||
regValueBuff = QByteArray(reinterpret_cast<const char*>(&i), sizeof(qint32));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -713,7 +713,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
|
||||
case QVariant::ULongLong: {
|
||||
type = REG_QWORD;
|
||||
qint64 i = value.toLongLong();
|
||||
regValueBuff = QByteArray((const char*)&i, sizeof(qint64));
|
||||
regValueBuff = QByteArray(reinterpret_cast<const char*>(&i), sizeof(qint64));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -725,11 +725,11 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
|
||||
// string type. Otherwise we use REG_BINARY.
|
||||
QString s = variantToString(value);
|
||||
type = s.contains(QChar::Null) ? REG_BINARY : REG_SZ;
|
||||
if (type == REG_BINARY) {
|
||||
regValueBuff = QByteArray((const char*)s.utf16(), s.length() * 2);
|
||||
} else {
|
||||
regValueBuff = QByteArray((const char*)s.utf16(), (s.length() + 1) * 2);
|
||||
}
|
||||
int length = s.length();
|
||||
if (type == REG_SZ)
|
||||
++length;
|
||||
regValueBuff = QByteArray(reinterpret_cast<const char *>(s.utf16()),
|
||||
int(sizeof(wchar_t)) * length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void WINAPI QT_WIN_CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/,
|
||||
{
|
||||
if (!timerId) // sanity check
|
||||
return;
|
||||
WinTimerInfo *t = (WinTimerInfo*)user;
|
||||
auto t = reinterpret_cast<WinTimerInfo*>(user);
|
||||
Q_ASSERT(t);
|
||||
QCoreApplication::postEvent(t->dispatcher, new QTimerEvent(t->timerId));
|
||||
}
|
||||
@ -146,9 +146,9 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
|
||||
}
|
||||
|
||||
#ifdef GWLP_USERDATA
|
||||
QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
auto q = reinterpret_cast<QEventDispatcherWin32 *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
|
||||
#else
|
||||
QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA);
|
||||
auto q = reinterpret_cast<QEventDispatcherWin32 *>(GetWindowLong(hwnd, GWL_USERDATA));
|
||||
#endif
|
||||
QEventDispatcherWin32Private *d = 0;
|
||||
if (q != 0)
|
||||
@ -369,9 +369,9 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch
|
||||
}
|
||||
|
||||
#ifdef GWLP_USERDATA
|
||||
SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG_PTR)eventDispatcher);
|
||||
SetWindowLongPtr(wnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(eventDispatcher));
|
||||
#else
|
||||
SetWindowLong(wnd, GWL_USERDATA, (LONG)eventDispatcher);
|
||||
SetWindowLong(wnd, GWL_USERDATA, reinterpret_cast<LONG>(eventDispatcher));
|
||||
#endif
|
||||
|
||||
return wnd;
|
||||
@ -603,7 +603,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
if (haveMessage) {
|
||||
// WinCE doesn't support hooks at all, so we have to call this by hand :(
|
||||
if (!d->getMessageHook)
|
||||
(void) qt_GetMessageHook(0, PM_REMOVE, (LPARAM) &msg);
|
||||
(void) qt_GetMessageHook(0, PM_REMOVE, reinterpret_cast<LPARAM>(&msg));
|
||||
|
||||
if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) {
|
||||
if (seenWM_QT_SENDPOSTEDEVENTS) {
|
||||
|
@ -101,7 +101,8 @@ HANDLE QSharedMemoryPrivate::handle()
|
||||
#if defined(Q_OS_WINRT)
|
||||
hand = OpenFileMappingFromApp(FILE_MAP_ALL_ACCESS, FALSE, reinterpret_cast<PCWSTR>(nativeKey.utf16()));
|
||||
#else
|
||||
hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16());
|
||||
hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false,
|
||||
reinterpret_cast<const wchar_t*>(nativeKey.utf16()));
|
||||
#endif
|
||||
if (!hand) {
|
||||
setErrorString(function);
|
||||
@ -133,9 +134,11 @@ bool QSharedMemoryPrivate::create(int size)
|
||||
|
||||
// Create the file mapping.
|
||||
#if defined(Q_OS_WINRT)
|
||||
hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, size, (PCWSTR)nativeKey.utf16());
|
||||
hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, size,
|
||||
reinterpret_cast<PCWSTR>(nativeKey.utf16()));
|
||||
#else
|
||||
hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)nativeKey.utf16());
|
||||
hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size,
|
||||
reinterpret_cast<const wchar_t*>(nativeKey.utf16()));
|
||||
#endif
|
||||
setErrorString(function);
|
||||
|
||||
|
@ -86,9 +86,12 @@ HANDLE QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
|
||||
// Create it if it doesn't already exists.
|
||||
if (semaphore == 0) {
|
||||
#if defined(Q_OS_WINRT)
|
||||
semaphore = CreateSemaphoreEx(0, initialValue, MAXLONG, (wchar_t*)fileName.utf16(), 0, SEMAPHORE_ALL_ACCESS);
|
||||
semaphore = CreateSemaphoreEx(0, initialValue, MAXLONG,
|
||||
reinterpret_cast<const wchar_t*>(fileName.utf16()),
|
||||
0, SEMAPHORE_ALL_ACCESS);
|
||||
#else
|
||||
semaphore = CreateSemaphore(0, initialValue, MAXLONG, (wchar_t*)fileName.utf16());
|
||||
semaphore = CreateSemaphore(0, initialValue, MAXLONG,
|
||||
reinterpret_cast<const wchar_t*>(fileName.utf16()));
|
||||
#endif
|
||||
if (semaphore == NULL)
|
||||
setErrorString(QLatin1String("QSystemSemaphore::handle"));
|
||||
|
@ -97,10 +97,10 @@ bool QLibraryPrivate::load_sys()
|
||||
|
||||
for (const QString &attempt : qAsConst(attempts)) {
|
||||
#ifndef Q_OS_WINRT
|
||||
pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16());
|
||||
pHnd = LoadLibrary(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(attempt).utf16()));
|
||||
#else // Q_OS_WINRT
|
||||
QString path = QDir::toNativeSeparators(QDir::current().relativeFilePath(attempt));
|
||||
pHnd = LoadPackagedLibrary((LPCWSTR)path.utf16(), 0);
|
||||
pHnd = LoadPackagedLibrary(reinterpret_cast<LPCWSTR>(path.utf16()), 0);
|
||||
if (pHnd)
|
||||
qualifiedFileName = attempt;
|
||||
#endif // !Q_OS_WINRT
|
||||
|
@ -121,7 +121,7 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
|
||||
fullPathAttempt.append(QLatin1Char('\\'));
|
||||
}
|
||||
fullPathAttempt.append(fileName);
|
||||
HINSTANCE inst = ::LoadLibrary((const wchar_t *)fullPathAttempt.utf16());
|
||||
HINSTANCE inst = ::LoadLibrary(reinterpret_cast<const wchar_t *>(fullPathAttempt.utf16()));
|
||||
if (inst != 0)
|
||||
return inst;
|
||||
}
|
||||
|
@ -318,7 +318,8 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
|
||||
|
||||
__try
|
||||
{
|
||||
RaiseException(0x406D1388, 0, sizeof(info)/sizeof(DWORD), (const ULONG_PTR*)&info);
|
||||
RaiseException(0x406D1388, 0, sizeof(info)/sizeof(DWORD),
|
||||
reinterpret_cast<const ULONG_PTR*>(&info));
|
||||
}
|
||||
__except (EXCEPTION_CONTINUE_EXECUTION)
|
||||
{
|
||||
@ -365,7 +366,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
|
||||
#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
|
||||
// sets the name of the current thread.
|
||||
QByteArray objectName = thr->objectName().toLocal8Bit();
|
||||
qt_set_thread_name((HANDLE)-1,
|
||||
qt_set_thread_name(HANDLE(-1),
|
||||
objectName.isEmpty() ?
|
||||
thr->metaObject()->className() : objectName.constData());
|
||||
#endif
|
||||
@ -508,8 +509,9 @@ void QThread::start(Priority priority)
|
||||
this, CREATE_SUSPENDED, &(d->id));
|
||||
#else
|
||||
// MSVC -MD or -MDd or MinGW build
|
||||
d->handle = (Qt::HANDLE) CreateThread(NULL, d->stackSize, (LPTHREAD_START_ROUTINE)QThreadPrivate::start,
|
||||
this, CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&d->id));
|
||||
d->handle = CreateThread(nullptr, d->stackSize,
|
||||
reinterpret_cast<LPTHREAD_START_ROUTINE>(QThreadPrivate::start),
|
||||
this, CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&d->id));
|
||||
#endif // Q_OS_WINRT
|
||||
|
||||
if (!d->handle) {
|
||||
|
@ -274,7 +274,7 @@ QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution()
|
||||
QString &QSystemLocalePrivate::substituteDigits(QString &string)
|
||||
{
|
||||
ushort zero = zeroDigit().unicode();
|
||||
ushort *qch = (ushort *)string.data();
|
||||
ushort *qch = reinterpret_cast<ushort *>(string.data());
|
||||
for (ushort *end = qch + string.size(); qch != end; ++qch) {
|
||||
if (*qch >= '0' && *qch <= '9')
|
||||
*qch = zero + (*qch - '0');
|
||||
|
@ -140,15 +140,15 @@ bool equalTzi(const TIME_ZONE_INFORMATION &tzi1, const TIME_ZONE_INFORMATION &tz
|
||||
#ifdef QT_USE_REGISTRY_TIMEZONE
|
||||
bool openRegistryKey(const QString &keyPath, HKEY *key)
|
||||
{
|
||||
return (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (const wchar_t*)keyPath.utf16(), 0, KEY_READ, key)
|
||||
== ERROR_SUCCESS);
|
||||
return RegOpenKeyEx(HKEY_LOCAL_MACHINE, reinterpret_cast<const wchar_t*>(keyPath.utf16()),
|
||||
0, KEY_READ, key) == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
QString readRegistryString(const HKEY &key, const wchar_t *value)
|
||||
{
|
||||
wchar_t buffer[MAX_PATH] = {0};
|
||||
DWORD size = sizeof(wchar_t) * MAX_PATH;
|
||||
RegQueryValueEx(key, (LPCWSTR)value, NULL, NULL, (LPBYTE)buffer, &size);
|
||||
RegQueryValueEx(key, value, nullptr, nullptr, reinterpret_cast<LPBYTE>(buffer), &size);
|
||||
return QString::fromWCharArray(buffer);
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ int readRegistryValue(const HKEY &key, const wchar_t *value)
|
||||
{
|
||||
DWORD buffer;
|
||||
DWORD size = sizeof(buffer);
|
||||
RegQueryValueEx(key, (LPCWSTR)value, NULL, NULL, (LPBYTE)&buffer, &size);
|
||||
RegQueryValueEx(key, value, nullptr, nullptr, reinterpret_cast<LPBYTE>(&buffer), &size);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ QWinTimeZonePrivate::QWinTransitionRule readRegistryRule(const HKEY &key,
|
||||
QWinTimeZonePrivate::QWinTransitionRule rule;
|
||||
REG_TZI_FORMAT tzi;
|
||||
DWORD tziSize = sizeof(tzi);
|
||||
if (RegQueryValueEx(key, (LPCWSTR)value, NULL, NULL, (BYTE *)&tzi, &tziSize)
|
||||
if (RegQueryValueEx(key, value, nullptr, nullptr, reinterpret_cast<BYTE *>(&tzi), &tziSize)
|
||||
== ERROR_SUCCESS) {
|
||||
rule.startYear = 0;
|
||||
rule.standardTimeBias = tzi.Bias + tzi.StandardBias;
|
||||
@ -192,12 +192,12 @@ TIME_ZONE_INFORMATION getRegistryTzi(const QByteArray &windowsId, bool *ok)
|
||||
if (openRegistryKey(tziKeyPath, &key)) {
|
||||
|
||||
DWORD size = sizeof(tzi.DaylightName);
|
||||
RegQueryValueEx(key, L"Dlt", NULL, NULL, (LPBYTE)tzi.DaylightName, &size);
|
||||
RegQueryValueEx(key, L"Dlt", nullptr, nullptr, reinterpret_cast<LPBYTE>(tzi.DaylightName), &size);
|
||||
|
||||
size = sizeof(tzi.StandardName);
|
||||
RegQueryValueEx(key, L"Std", NULL, NULL, (LPBYTE)tzi.StandardName, &size);
|
||||
RegQueryValueEx(key, L"Std", nullptr, nullptr, reinterpret_cast<LPBYTE>(tzi.StandardName), &size);
|
||||
|
||||
if (RegQueryValueEx(key, L"TZI", NULL, NULL, (BYTE *) ®Tzi, ®TziSize)
|
||||
if (RegQueryValueEx(key, L"TZI", nullptr, nullptr, reinterpret_cast<BYTE *>(®Tzi), ®TziSize)
|
||||
== ERROR_SUCCESS) {
|
||||
tzi.Bias = regTzi.Bias;
|
||||
tzi.StandardBias = regTzi.StandardBias;
|
||||
@ -590,7 +590,7 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
|
||||
for (int year = startYear; year <= endYear; ++year) {
|
||||
bool ruleOk;
|
||||
QWinTransitionRule rule = readRegistryRule(dynamicKey,
|
||||
(LPCWSTR)QString::number(year).utf16(),
|
||||
reinterpret_cast<LPCWSTR>(QString::number(year).utf16()),
|
||||
&ruleOk);
|
||||
if (ruleOk
|
||||
// Don't repeat a recurrent rule:
|
||||
|
@ -92,13 +92,13 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
|
||||
sockaddr *sa;
|
||||
QT_SOCKLEN_T saSize;
|
||||
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||
sa = (sockaddr *)&sa4;
|
||||
sa = reinterpret_cast<sockaddr *>(&sa4);
|
||||
saSize = sizeof(sa4);
|
||||
memset(&sa4, 0, sizeof(sa4));
|
||||
sa4.sin_family = AF_INET;
|
||||
sa4.sin_addr.s_addr = htonl(address.toIPv4Address());
|
||||
} else {
|
||||
sa = (sockaddr *)&sa6;
|
||||
sa = reinterpret_cast<sockaddr *>(&sa6);
|
||||
saSize = sizeof(sa6);
|
||||
memset(&sa6, 0, sizeof(sa6));
|
||||
sa6.sin6_family = AF_INET6;
|
||||
@ -132,14 +132,14 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
|
||||
switch (p->ai_family) {
|
||||
case AF_INET: {
|
||||
QHostAddress addr;
|
||||
addr.setAddress(ntohl(((sockaddr_in *) p->ai_addr)->sin_addr.s_addr));
|
||||
addr.setAddress(ntohl(reinterpret_cast<sockaddr_in *>(p->ai_addr)->sin_addr.s_addr));
|
||||
if (!addresses.contains(addr))
|
||||
addresses.append(addr);
|
||||
}
|
||||
break;
|
||||
case AF_INET6: {
|
||||
QHostAddress addr;
|
||||
addr.setAddress(((sockaddr_in6 *) p->ai_addr)->sin6_addr.s6_addr);
|
||||
addr.setAddress(reinterpret_cast<const sockaddr_in6 *>(p->ai_addr)->sin6_addr.s6_addr);
|
||||
if (!addresses.contains(addr))
|
||||
addresses.append(addr);
|
||||
}
|
||||
|
@ -74,15 +74,16 @@ static QHostAddress addressFromSockaddr(sockaddr *sa)
|
||||
if (!sa)
|
||||
return address;
|
||||
|
||||
if (sa->sa_family == AF_INET)
|
||||
address.setAddress(htonl(((sockaddr_in *)sa)->sin_addr.s_addr));
|
||||
else if (sa->sa_family == AF_INET6) {
|
||||
address.setAddress(((sockaddr_in6 *)sa)->sin6_addr.s6_addr);
|
||||
int scope = ((sockaddr_in6 *)sa)->sin6_scope_id;
|
||||
if (scope)
|
||||
address.setScopeId(QNetworkInterfaceManager::interfaceNameFromIndex(scope));
|
||||
} else
|
||||
if (sa->sa_family == AF_INET) {
|
||||
address.setAddress(htonl(reinterpret_cast<const sockaddr_in *>(sa)->sin_addr.s_addr));
|
||||
} else if (sa->sa_family == AF_INET6) {
|
||||
auto sai6 = reinterpret_cast<const sockaddr_in6 *>(sa);
|
||||
address.setAddress(sai6->sin6_addr.s6_addr);
|
||||
if (sai6->sin6_scope_id)
|
||||
address.setScopeId(QNetworkInterfaceManager::interfaceNameFromIndex(sai6->sin6_scope_id));
|
||||
} else {
|
||||
qWarning("Got unknown socket family %d", sa->sa_family);
|
||||
}
|
||||
return address;
|
||||
|
||||
}
|
||||
@ -121,7 +122,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
|
||||
ULONG retval = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAdapter, &bufSize);
|
||||
if (retval == ERROR_BUFFER_OVERFLOW) {
|
||||
// need more memory
|
||||
pAdapter = (IP_ADAPTER_ADDRESSES *)malloc(bufSize);
|
||||
pAdapter = reinterpret_cast<IP_ADAPTER_ADDRESSES *>(malloc(bufSize));
|
||||
if (!pAdapter)
|
||||
return interfaces;
|
||||
// try again
|
||||
@ -255,7 +256,7 @@ QString QHostInfo::localDomainName()
|
||||
ULONG bufSize = sizeof info;
|
||||
pinfo = &info;
|
||||
if (GetNetworkParams(pinfo, &bufSize) == ERROR_BUFFER_OVERFLOW) {
|
||||
pinfo = (FIXED_INFO *)malloc(bufSize);
|
||||
pinfo = reinterpret_cast<FIXED_INFO *>(malloc(bufSize));
|
||||
if (!pinfo)
|
||||
return QString();
|
||||
// try again
|
||||
|
@ -566,7 +566,7 @@ void QWindowsSystemProxy::init()
|
||||
WINHTTP_AUTO_DETECT_TYPE_DNS_A;
|
||||
} else {
|
||||
autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
|
||||
autoProxyOptions.lpszAutoConfigUrl = (LPCWSTR)autoConfigUrl.utf16();
|
||||
autoProxyOptions.lpszAutoConfigUrl = reinterpret_cast<LPCWSTR>(autoConfigUrl.utf16());
|
||||
}
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
|
||||
}
|
||||
|
||||
bool getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
|
||||
(LPCWSTR)urlQueryString.utf16(),
|
||||
reinterpret_cast<LPCWSTR>(urlQueryString.utf16()),
|
||||
&sp->autoProxyOptions,
|
||||
&proxyInfo);
|
||||
DWORD getProxyError = GetLastError();
|
||||
@ -623,9 +623,10 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
|
||||
} else {
|
||||
//pac file URL is specified as well, try using that
|
||||
sp->autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
|
||||
sp->autoProxyOptions.lpszAutoConfigUrl = (LPCWSTR)sp->autoConfigUrl.utf16();
|
||||
sp->autoProxyOptions.lpszAutoConfigUrl =
|
||||
reinterpret_cast<LPCWSTR>(sp->autoConfigUrl.utf16());
|
||||
getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
|
||||
(LPCWSTR)urlQueryString.utf16(),
|
||||
reinterpret_cast<LPCWSTR>(urlQueryString.utf16()),
|
||||
&sp->autoProxyOptions,
|
||||
&proxyInfo);
|
||||
getProxyError = GetLastError();
|
||||
@ -638,7 +639,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
|
||||
// But now we've to enable it (http://msdn.microsoft.com/en-us/library/aa383153%28v=VS.85%29.aspx)
|
||||
sp->autoProxyOptions.fAutoLogonIfChallenged = TRUE;
|
||||
getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
|
||||
(LPCWSTR)urlQueryString.utf16(),
|
||||
reinterpret_cast<LPCWSTR>(urlQueryString.utf16()),
|
||||
&sp->autoProxyOptions,
|
||||
&proxyInfo);
|
||||
getProxyError = GetLastError();
|
||||
|
@ -89,7 +89,7 @@ bool QLocalServerPrivate::addListener()
|
||||
DWORD dwBufferSize = 0;
|
||||
GetTokenInformation(hToken, TokenUser, 0, 0, &dwBufferSize);
|
||||
tokenUserBuffer.fill(0, dwBufferSize);
|
||||
PTOKEN_USER pTokenUser = (PTOKEN_USER)tokenUserBuffer.data();
|
||||
auto pTokenUser = reinterpret_cast<PTOKEN_USER>(tokenUserBuffer.data());
|
||||
if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwBufferSize, &dwBufferSize)) {
|
||||
setError(QLatin1String("QLocalServerPrivate::addListener"));
|
||||
CloseHandle(hToken);
|
||||
@ -99,7 +99,7 @@ bool QLocalServerPrivate::addListener()
|
||||
dwBufferSize = 0;
|
||||
GetTokenInformation(hToken, TokenPrimaryGroup, 0, 0, &dwBufferSize);
|
||||
tokenGroupBuffer.fill(0, dwBufferSize);
|
||||
PTOKEN_PRIMARY_GROUP pTokenGroup = (PTOKEN_PRIMARY_GROUP)tokenGroupBuffer.data();
|
||||
auto pTokenGroup = reinterpret_cast<PTOKEN_PRIMARY_GROUP>(tokenGroupBuffer.data());
|
||||
if (!GetTokenInformation(hToken, TokenPrimaryGroup, pTokenGroup, dwBufferSize, &dwBufferSize)) {
|
||||
setError(QLatin1String("QLocalServerPrivate::addListener"));
|
||||
CloseHandle(hToken);
|
||||
@ -140,7 +140,7 @@ bool QLocalServerPrivate::addListener()
|
||||
aclSize = (aclSize + (sizeof(DWORD) - 1)) & 0xfffffffc;
|
||||
|
||||
aclBuffer.fill(0, aclSize);
|
||||
PACL acl = (PACL)aclBuffer.data();
|
||||
auto acl = reinterpret_cast<PACL>(aclBuffer.data());
|
||||
InitializeAcl(acl, aclSize, ACL_REVISION_DS);
|
||||
|
||||
if (socketOptions & QLocalServer::UserAccessOption) {
|
||||
@ -176,7 +176,7 @@ bool QLocalServerPrivate::addListener()
|
||||
}
|
||||
|
||||
listener.handle = CreateNamedPipe(
|
||||
(const wchar_t *)fullServerName.utf16(), // pipe name
|
||||
reinterpret_cast<const wchar_t *>(fullServerName.utf16()), // pipe name
|
||||
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, // read/write access
|
||||
PIPE_TYPE_BYTE | // byte type pipe
|
||||
PIPE_READMODE_BYTE | // byte-read mode
|
||||
@ -299,7 +299,7 @@ void QLocalServerPrivate::_q_onNewConnection()
|
||||
tryAgain = true;
|
||||
|
||||
// Make this the last thing so connected slots can wreak the least havoc
|
||||
q->incomingConnection((quintptr)handle);
|
||||
q->incomingConnection(reinterpret_cast<quintptr>(handle));
|
||||
} else {
|
||||
if (GetLastError() != ERROR_IO_INCOMPLETE) {
|
||||
q->close();
|
||||
|
@ -155,7 +155,7 @@ void QLocalSocket::connectToServer(OpenMode openMode)
|
||||
forever {
|
||||
DWORD permissions = (openMode & QIODevice::ReadOnly) ? GENERIC_READ : 0;
|
||||
permissions |= (openMode & QIODevice::WriteOnly) ? GENERIC_WRITE : 0;
|
||||
localSocket = CreateFile((const wchar_t *)d->fullServerName.utf16(), // pipe name
|
||||
localSocket = CreateFile(reinterpret_cast<const wchar_t *>(d->fullServerName.utf16()), // pipe name
|
||||
permissions,
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
@ -183,7 +183,7 @@ void QLocalSocket::connectToServer(OpenMode openMode)
|
||||
}
|
||||
|
||||
// we have a valid handle
|
||||
if (setSocketDescriptor((qintptr)localSocket, ConnectedState, openMode))
|
||||
if (setSocketDescriptor(reinterpret_cast<qintptr>(localSocket), ConnectedState, openMode))
|
||||
emit connected();
|
||||
}
|
||||
|
||||
@ -371,7 +371,7 @@ void QLocalSocketPrivate::_q_canWrite()
|
||||
qintptr QLocalSocket::socketDescriptor() const
|
||||
{
|
||||
Q_D(const QLocalSocket);
|
||||
return (qintptr)d->handle;
|
||||
return reinterpret_cast<qintptr>(d->handle);
|
||||
}
|
||||
|
||||
qint64 QLocalSocket::readBufferSize() const
|
||||
|
@ -294,7 +294,8 @@ static inline QAbstractSocket::SocketType qt_socket_getType(qintptr socketDescri
|
||||
{
|
||||
int value = 0;
|
||||
QT_SOCKLEN_T valueSize = sizeof(value);
|
||||
if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, (char *) &value, &valueSize) != 0) {
|
||||
if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE,
|
||||
reinterpret_cast<char *>(&value), &valueSize) != 0) {
|
||||
WS_ERROR_DEBUG(WSAGetLastError());
|
||||
} else {
|
||||
if (value == SOCK_STREAM)
|
||||
@ -361,7 +362,7 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
|
||||
#ifdef HANDLE_FLAG_INHERIT
|
||||
if (socket != INVALID_SOCKET) {
|
||||
// make non inheritable the old way
|
||||
BOOL handleFlags = SetHandleInformation((HANDLE)socket, HANDLE_FLAG_INHERIT, 0);
|
||||
BOOL handleFlags = SetHandleInformation(reinterpret_cast<HANDLE>(socket), HANDLE_FLAG_INHERIT, 0);
|
||||
#ifdef QNATIVESOCKETENGINE_DEBUG
|
||||
qDebug() << "QNativeSocketEnginePrivate::createNewSocket - set inheritable" << handleFlags;
|
||||
#else
|
||||
@ -1443,7 +1444,7 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
|
||||
|
||||
for (;;) {
|
||||
WSABUF buf;
|
||||
buf.buf = (char*)data + ret;
|
||||
buf.buf = const_cast<char*>(data) + ret;
|
||||
buf.len = bytesToSend;
|
||||
DWORD flags = 0;
|
||||
DWORD bytesWritten = 0;
|
||||
|
@ -1608,7 +1608,8 @@ void QWindowsFontDatabase::removeApplicationFonts()
|
||||
if (font.handle) {
|
||||
RemoveFontMemResourceEx(font.handle);
|
||||
} else {
|
||||
RemoveFontResourceExW((LPCWSTR)font.fileName.utf16(), FR_PRIVATE, 0);
|
||||
RemoveFontResourceExW(reinterpret_cast<LPCWSTR>(font.fileName.utf16()),
|
||||
FR_PRIVATE, nullptr);
|
||||
}
|
||||
}
|
||||
m_applicationFonts.clear();
|
||||
@ -1652,7 +1653,8 @@ void QWindowsFontDatabase::refUniqueFont(const QString &uniqueFont)
|
||||
// ### fixme Qt 6 (QTBUG-58610): See comment at QWindowsFontDatabase::systemDefaultFont()
|
||||
HFONT QWindowsFontDatabase::systemFont()
|
||||
{
|
||||
static const HFONT stock_sysfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
|
||||
static const auto stock_sysfont =
|
||||
reinterpret_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT));
|
||||
return stock_sysfont;
|
||||
}
|
||||
|
||||
|
@ -111,9 +111,8 @@ QFixed QWindowsFontEngine::lineThickness() const
|
||||
|
||||
static OUTLINETEXTMETRIC *getOutlineTextMetric(HDC hdc)
|
||||
{
|
||||
int size;
|
||||
size = GetOutlineTextMetrics(hdc, 0, 0);
|
||||
OUTLINETEXTMETRIC *otm = (OUTLINETEXTMETRIC *)malloc(size);
|
||||
const auto size = GetOutlineTextMetrics(hdc, 0, nullptr);
|
||||
auto otm = reinterpret_cast<OUTLINETEXTMETRIC *>(malloc(size));
|
||||
GetOutlineTextMetrics(hdc, size, otm);
|
||||
return otm;
|
||||
}
|
||||
@ -1140,7 +1139,7 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra
|
||||
|
||||
QImage rgbMask(mask->width(), mask->height(), QImage::Format_RGB32);
|
||||
for (int y=0; y<mask->height(); ++y) {
|
||||
uint *dest = (uint *) rgbMask.scanLine(y);
|
||||
auto dest = reinterpret_cast<uint *>(rgbMask.scanLine(y));
|
||||
const uint *src = reinterpret_cast<const uint *>(source.constScanLine(y));
|
||||
for (int x=0; x<mask->width(); ++x) {
|
||||
dest[x] = 0xffffffff - (0x00ffffff & src[x]);
|
||||
|
@ -112,7 +112,7 @@ QWindowsPrintDevice::QWindowsPrintDevice(const QString &id)
|
||||
{
|
||||
// First do a fast lookup to see if printer exists, if it does then open it
|
||||
if (!id.isEmpty() && QWindowsPrintDevice::availablePrintDeviceIds().contains(id)) {
|
||||
if (OpenPrinter((LPWSTR)m_id.utf16(), &m_hPrinter, NULL)) {
|
||||
if (OpenPrinter(const_cast<LPWSTR>(wcharId()), &m_hPrinter, nullptr)) {
|
||||
DWORD needed = 0;
|
||||
GetPrinter(m_hPrinter, 2, 0, 0, &needed);
|
||||
QScopedArrayPointer<BYTE> buffer(new BYTE[needed]);
|
||||
@ -351,16 +351,19 @@ int QWindowsPrintDevice::defaultResolution() const
|
||||
|
||||
void QWindowsPrintDevice::loadInputSlots() const
|
||||
{
|
||||
DWORD binCount = DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_BINS, NULL, NULL);
|
||||
const auto printerId = wcharId();
|
||||
DWORD binCount = DeviceCapabilities(printerId, nullptr, DC_BINS, nullptr, nullptr);
|
||||
if (int(binCount) > 0
|
||||
&& DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_BINNAMES, NULL, NULL) == binCount) {
|
||||
&& DeviceCapabilities(printerId, nullptr, DC_BINNAMES, nullptr, nullptr) == binCount) {
|
||||
|
||||
QScopedArrayPointer<WORD> bins(new WORD[binCount*sizeof(WORD)]);
|
||||
QScopedArrayPointer<wchar_t> binNames(new wchar_t[binCount*24]);
|
||||
|
||||
// Get the details and match the default paper size
|
||||
if (DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_BINS, (LPWSTR)bins.data(), NULL) == binCount
|
||||
&& DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_BINNAMES, binNames.data(), NULL) == binCount) {
|
||||
if (DeviceCapabilities(printerId, nullptr, DC_BINS,
|
||||
reinterpret_cast<LPWSTR>(bins.data()), nullptr) == binCount
|
||||
&& DeviceCapabilities(printerId, nullptr, DC_BINNAMES, binNames.data(),
|
||||
nullptr) == binCount) {
|
||||
|
||||
for (int i = 0; i < int(binCount); ++i) {
|
||||
wchar_t *binName = binNames.data() + (i * 24);
|
||||
@ -410,7 +413,7 @@ void QWindowsPrintDevice::loadOutputBins() const
|
||||
void QWindowsPrintDevice::loadDuplexModes() const
|
||||
{
|
||||
m_duplexModes.append(QPrint::DuplexNone);
|
||||
DWORD duplex = DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_DUPLEX, NULL, NULL);
|
||||
DWORD duplex = DeviceCapabilities(wcharId(), nullptr, DC_DUPLEX, nullptr, nullptr);
|
||||
if (int(duplex) == 1) {
|
||||
// TODO Assume if duplex flag supports both modes
|
||||
m_duplexModes.append(QPrint::DuplexAuto);
|
||||
@ -444,7 +447,7 @@ QPrint::DuplexMode QWindowsPrintDevice::defaultDuplexMode() const
|
||||
void QWindowsPrintDevice::loadColorModes() const
|
||||
{
|
||||
m_colorModes.append(QPrint::GrayScale);
|
||||
DWORD color = DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_COLORDEVICE, NULL, NULL);
|
||||
DWORD color = DeviceCapabilities(wcharId(), nullptr, DC_COLORDEVICE, nullptr, nullptr);
|
||||
if (int(color) == 1)
|
||||
m_colorModes.append(QPrint::Color);
|
||||
m_haveColorModes = true;
|
||||
@ -503,7 +506,7 @@ QString QWindowsPrintDevice::defaultPrintDeviceId()
|
||||
|
||||
void QWindowsPrintDevice::loadCopiesSupport() const
|
||||
{
|
||||
LPWSTR printerId = const_cast<LPWSTR>(reinterpret_cast<LPCWSTR>(m_id.utf16()));
|
||||
auto printerId = wcharId();
|
||||
m_supportsMultipleCopies = (DeviceCapabilities(printerId, NULL, DC_COPIES, NULL, NULL) > 1);
|
||||
m_supportsCollateCopies = DeviceCapabilities(printerId, NULL, DC_COLLATE, NULL, NULL);
|
||||
m_haveCopies = true;
|
||||
@ -552,7 +555,7 @@ void QWindowsPrintDevice::loadMinMaxPageSizes() const
|
||||
{
|
||||
// Min/Max custom size is in tenths of a millimeter
|
||||
const qreal multiplier = qt_pointMultiplier(QPageLayout::Millimeter);
|
||||
LPWSTR printerId = const_cast<LPWSTR>(reinterpret_cast<LPCWSTR>(m_id.utf16()));
|
||||
auto printerId = wcharId();
|
||||
DWORD min = DeviceCapabilities(printerId, NULL, DC_MINEXTENT, NULL, NULL);
|
||||
m_minimumPhysicalPageSize = QSize((LOWORD(min) / 10.0) * multiplier, (HIWORD(min) / 10.0) * multiplier);
|
||||
DWORD max = DeviceCapabilities(printerId, NULL, DC_MAXEXTENT, NULL, NULL);
|
||||
|
@ -140,6 +140,8 @@ protected:
|
||||
void loadMinMaxPageSizes() const;
|
||||
|
||||
private:
|
||||
LPCWSTR wcharId() const { return reinterpret_cast<LPCWSTR>(m_id.utf16()); }
|
||||
|
||||
HANDLE m_hPrinter;
|
||||
mutable bool m_haveCopies;
|
||||
mutable bool m_haveMinMaxPageSizes;
|
||||
|
@ -1556,14 +1556,15 @@ HGLOBAL *QWin32PrintEngine::createGlobalDevNames()
|
||||
Q_D(QWin32PrintEngine);
|
||||
|
||||
int size = sizeof(DEVNAMES) + d->m_printDevice.id().length() * 2 + 2;
|
||||
HGLOBAL *hGlobal = (HGLOBAL *) GlobalAlloc(GMEM_MOVEABLE, size);
|
||||
DEVNAMES *dn = (DEVNAMES*) GlobalLock(hGlobal);
|
||||
auto hGlobal = reinterpret_cast<HGLOBAL *>(GlobalAlloc(GMEM_MOVEABLE, size));
|
||||
auto dn = reinterpret_cast<DEVNAMES*>(GlobalLock(hGlobal));
|
||||
|
||||
dn->wDriverOffset = 0;
|
||||
dn->wDeviceOffset = sizeof(DEVNAMES) / sizeof(wchar_t);
|
||||
dn->wOutputOffset = 0;
|
||||
|
||||
memcpy((ushort*)dn + dn->wDeviceOffset, d->m_printDevice.id().utf16(), d->m_printDevice.id().length() * 2 + 2);
|
||||
memcpy(reinterpret_cast<ushort*>(dn) + dn->wDeviceOffset,
|
||||
d->m_printDevice.id().utf16(), d->m_printDevice.id().length() * 2 + 2);
|
||||
dn->wDefault = 0;
|
||||
|
||||
GlobalUnlock(hGlobal);
|
||||
@ -1574,8 +1575,9 @@ void QWin32PrintEngine::setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalD
|
||||
{
|
||||
Q_D(QWin32PrintEngine);
|
||||
if (globalDevNames) {
|
||||
DEVNAMES *dn = (DEVNAMES*) GlobalLock(globalDevNames);
|
||||
QString id = QString::fromWCharArray((wchar_t*)(dn) + dn->wDeviceOffset);
|
||||
auto dn = reinterpret_cast<DEVNAMES*>(GlobalLock(globalDevNames));
|
||||
const QString id =
|
||||
QString::fromWCharArray(reinterpret_cast<const wchar_t*>(dn) + dn->wDeviceOffset);
|
||||
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
|
||||
if (ps)
|
||||
d->m_printDevice = ps->createPrintDevice(id.isEmpty() ? ps->defaultPrintDeviceId() : id);
|
||||
@ -1583,7 +1585,7 @@ void QWin32PrintEngine::setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalD
|
||||
}
|
||||
|
||||
if (globalDevMode) {
|
||||
DEVMODE *dm = (DEVMODE*) GlobalLock(globalDevMode);
|
||||
auto dm = reinterpret_cast<DEVMODE*>(GlobalLock(globalDevMode));
|
||||
d->release();
|
||||
d->globalDevMode = globalDevMode;
|
||||
if (d->ownsDevMode) {
|
||||
|
@ -606,8 +606,8 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
|
||||
// Set up the DC
|
||||
const LOGFONT captionLogFont = getCaptionLogFont(hTheme);
|
||||
const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont);
|
||||
HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp);
|
||||
HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont);
|
||||
auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp));
|
||||
auto hOldFont = reinterpret_cast<HFONT>(SelectObject(dcMem, (HGDIOBJ) hCaptionFont));
|
||||
|
||||
// Draw the text!
|
||||
DTTOPTS dto;
|
||||
@ -654,7 +654,7 @@ bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc)
|
||||
dib.bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
|
||||
HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp);
|
||||
auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp));
|
||||
|
||||
BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY);
|
||||
SelectObject(dcMem, (HGDIOBJ) hOldBmp);
|
||||
|
Loading…
Reference in New Issue
Block a user