aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-09-08 09:07:07 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-09-08 16:18:24 +0000
commitac9276eeb9e2dd31345600a497c4d65009ae9577 (patch)
tree30dbf42483feb5e86e1b7fcd9b0b1cc34c23b352 /src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
parent7d9f4320533026c9ee9378412d58b9709b018d74 (diff)
Avoid crashing when not having a screen for the context
Disconnecting the screen to which the context belongs results in a null QOpenGLContext::screen(). Fall back to qguiapp's devicePixelRatio() in this case (giving the highest dpi in the system) due to the lack of any other option. This will fix the crashes when rendering offscreen (QQuickWidget) and using native text rendering. Without this the render attempt after disconnecting the screen with which the context was created would crash due to accessing the already destroyed screen instance. Task-number: QTBUG-42803 Change-Id: Ie5889f59e5d66d09329b3d5fb8e1365d14d5b8fc Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultglyphnode_p.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 14bc0fad07..9f8788123b 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -73,7 +73,7 @@ static inline int qsg_device_pixel_ratio(QOpenGLContext *ctx)
else
devicePixelRatio = w->devicePixelRatio();
} else {
- devicePixelRatio = ctx->screen()->devicePixelRatio();
+ devicePixelRatio = ctx->screen() ? ctx->screen()->devicePixelRatio() : qGuiApp->devicePixelRatio();
}
return devicePixelRatio;
}