Windows QPA: suppress warning message when not needed
We have done the same thing when calling SetProcessDpiAwareness(), but it's also needed for SetProcessDpiAwarenessContext(), otherwise there will always be a warning message when the user uses a manifest file to set the DPI awareness mode for the application (which is highly recommended by Microsoft). Change-Id: I31894d41c89581b6edd7826cb3dabad492f6c2a8 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 19857fda75d049e64e39ff353d7f5ed3bd342d61)
This commit is contained in:
parent
210e036488
commit
1327536264
@ -381,8 +381,8 @@ void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiA
|
||||
const HRESULT hr = SetProcessDpiAwareness(static_cast<PROCESS_DPI_AWARENESS>(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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user