diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a714a6b3e70..41d66bdee91 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -381,8 +381,8 @@ void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiA const HRESULT hr = SetProcessDpiAwareness(static_cast(dpiAwareness)); // E_ACCESSDENIED means set externally (MSVC manifest or external app loading Qt plugin). // Silence warning in that case unless debug is enabled. - if (FAILED(hr) && (hr != E_ACCESSDENIED || lcQpaWindows().isDebugEnabled())) { - qWarning().noquote().nospace() << "SetProcessDpiAwareness(" + if (FAILED(hr) && hr != E_ACCESSDENIED) { + qCWarning(lcQpaWindows).noquote().nospace() << "SetProcessDpiAwareness(" << dpiAwareness << ") failed: " << QWindowsContext::comErrorString(hr) << ", using " << QWindowsContext::processDpiAwareness(); } @@ -393,12 +393,16 @@ bool QWindowsContext::setProcessDpiV2Awareness() qCDebug(lcQpaWindows) << __FUNCTION__; const BOOL ok = SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); if (!ok) { - const HRESULT errorCode = GetLastError(); - qCWarning(lcQpaWindows).noquote().nospace() << "setProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) failed: " - << QWindowsContext::comErrorString(errorCode); - return false; + const DWORD dwError = GetLastError(); + // ERROR_ACCESS_DENIED means set externally (MSVC manifest or external app loading Qt plugin). + // Silence warning in that case unless debug is enabled. + if (dwError != ERROR_ACCESS_DENIED) { + qCWarning(lcQpaWindows).noquote().nospace() + << "SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) failed: " + << QWindowsContext::comErrorString(HRESULT(dwError)); + return false; + } } - QWindowsContextPrivate::m_v2DpiAware = true; return true; }