From be09197784dae135aef1009d4207b5fbb573c54b Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 1 Apr 2022 15:46:52 +0800 Subject: [PATCH] win32: fix the d2d crash on win7 The function signature was wrong so it crashed. Now it won't crash anymore. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- src/core/utils_win.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index f0c789d..ee9e0d4 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -41,12 +41,10 @@ # include #endif #include "qwinregistry_p.h" -#include "framelesshelper_windows.h" #include "framelesswindowsmanager.h" -#if 0 +#include "framelesshelper_windows.h" #include #include -#endif Q_DECLARE_METATYPE(QMargins) @@ -744,13 +742,13 @@ quint32 Utils::getPrimaryScreenDpi(const bool horizontal) } } } -#if 0 // Crash on Windows 7, to be investigated. static const auto pD2D1CreateFactory = - reinterpret_cast( + reinterpret_cast( QSystemLibrary::resolve(kd2d1, "D2D1CreateFactory")); if (pD2D1CreateFactory) { CComPtr d2dFactory = nullptr; - if (SUCCEEDED(pD2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, IID_PPV_ARGS(&d2dFactory)))) { + if (SUCCEEDED(pD2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory), + nullptr, reinterpret_cast(&d2dFactory)))) { if (SUCCEEDED(d2dFactory->ReloadSystemMetrics())) { FLOAT dpiX = 0.0, dpiY = 0.0; QT_WARNING_PUSH @@ -761,7 +759,6 @@ quint32 Utils::getPrimaryScreenDpi(const bool horizontal) } } } -#endif const HDC hdc = GetDC(nullptr); if (hdc) { const int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);