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>
This commit is contained in:
Yuhang Zhao 2022-04-01 15:46:52 +08:00
parent 5c7434ea35
commit be09197784
1 changed files with 4 additions and 7 deletions

View File

@ -41,12 +41,10 @@
# include <QtGui/qpa/qplatformwindow_p.h> # include <QtGui/qpa/qplatformwindow_p.h>
#endif #endif
#include "qwinregistry_p.h" #include "qwinregistry_p.h"
#include "framelesshelper_windows.h"
#include "framelesswindowsmanager.h" #include "framelesswindowsmanager.h"
#if 0 #include "framelesshelper_windows.h"
#include <atlbase.h> #include <atlbase.h>
#include <d2d1.h> #include <d2d1.h>
#endif
Q_DECLARE_METATYPE(QMargins) 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 = static const auto pD2D1CreateFactory =
reinterpret_cast<HRESULT(WINAPI *)(D2D1_FACTORY_TYPE, REFIID, void **)>( reinterpret_cast<HRESULT(WINAPI *)(D2D1_FACTORY_TYPE, REFIID, CONST D2D1_FACTORY_OPTIONS *, void **)>(
QSystemLibrary::resolve(kd2d1, "D2D1CreateFactory")); QSystemLibrary::resolve(kd2d1, "D2D1CreateFactory"));
if (pD2D1CreateFactory) { if (pD2D1CreateFactory) {
CComPtr<ID2D1Factory> d2dFactory = nullptr; CComPtr<ID2D1Factory> 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<void **>(&d2dFactory)))) {
if (SUCCEEDED(d2dFactory->ReloadSystemMetrics())) { if (SUCCEEDED(d2dFactory->ReloadSystemMetrics())) {
FLOAT dpiX = 0.0, dpiY = 0.0; FLOAT dpiX = 0.0, dpiY = 0.0;
QT_WARNING_PUSH QT_WARNING_PUSH
@ -761,7 +759,6 @@ quint32 Utils::getPrimaryScreenDpi(const bool horizontal)
} }
} }
} }
#endif
const HDC hdc = GetDC(nullptr); const HDC hdc = GetDC(nullptr);
if (hdc) { if (hdc) {
const int dpiX = GetDeviceCaps(hdc, LOGPIXELSX); const int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);