Details
-
Bug
-
Resolution: Done
-
P4: Low
-
5.9.1
-
None
-
ea4fae0df689843fbcd6cf7f170d825557646ea2 (qtbase/5.9, 19.7.2017, 5.9.2)
Description
In QWindowsContext.cpp at line 950, QWindowsContext checks whether the window is top level before calling enableNonClientDpiScaling:
case QtWindows::NonClientCreate: if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10 && d->m_creationContext->window->isTopLevel()) enableNonClientDpiScaling(msg.hwnd); return false;
The isTopLevel() call is against the base QWindow class, rather than the QWindowsWindow class. Base QWindow returns true if parent is null, while QWindowsWindow additionally checks against an embedded bool which can be set via the property_q_embedded_native_parent_handle:
bool QWindow::isTopLevel() const { Q_D(const QWindow); return d->parentWindow == 0; }
vs
bool QWindowsWindow::isTopLevel() const { return window()->isTopLevel() && !m_data.embedded; }
Because there is no check against the embedded bool in the if statement, QWindowsContext proceeds with the call to enableNonClientDpiScaling which ultimately fails and reports as such via a qErrnoWarning call in QWindowsContext.cpp line 147.
EnableNonClientDpiScaling() failed for HWND 0x3d0614 (0) ()
The TrueFramelessWindow project is a small project using a native parent window that reproduces this bug @ https://github.com/dfct/TrueFramelessWindow
edit 07/18: the file in question is QWindowsContext.cpp line 950, not QWindowsWindow.cpp, my sincere apologies for the couple typos switching those!