Skip to content

Commit 576654b

Browse files
committed
fix possible QWKQuick crash
1 parent 153e1f4 commit 576654b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/quick/quickwindowagent_win.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ namespace QWK {
4747

4848
bool BorderItem::shouldEnableEmulatedPainter() const {
4949
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
50-
auto api = window()->rendererInterface()->graphicsApi();
50+
const QQuickWindow* win = window();
51+
if (!win) {
52+
return true;
53+
}
54+
auto api = win->rendererInterface()->graphicsApi();
5155
switch (api) {
5256
case QSGRendererInterface::OpenGL:
5357
// FIXME: experimental, try to find the exact fixed version.
@@ -97,7 +101,11 @@ namespace QWK {
97101
BorderItem::~BorderItem() = default;
98102

99103
void BorderItem::updateGeometry() {
100-
setHeight(borderThickness() / window()->devicePixelRatio());
104+
const QQuickWindow* win = window();
105+
if (!win) {
106+
return;
107+
}
108+
setHeight(borderThickness() / win->effectiveDevicePixelRatio());
101109
setVisible(isNormalWindow());
102110
}
103111

0 commit comments

Comments
 (0)