summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorDaiwei Li <daiweili@suitabletech.com>2013-08-13 15:41:04 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-23 11:48:00 +0200
commit79570157e3f2d49a016a63fbf3a2e6e00da08fe9 (patch)
tree05f1cddf9221db1bdc1505f33a6b0224c3cfe869 /src/plugins/platforms/cocoa
parent9194fc00a61379fa9ccd4b05c480f67b2fb739bc (diff)
Return 1.0 for devicePixelRatio in QCocoaWindow if no valid window
If m_window is invalid, devicePixelRatio returns 0, which leads to adverse effects in other parts of the code. For example, qquickshadereffectsource.cpp will get stuck in an infinite loop trying to multiply 0 by 2. Task-number: QTBUG-32975 Change-Id: Ie3db86f1f459df018ebce67bcb4226f6cffe854e Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 26869d4b5f..86f12e0e5f 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1007,7 +1007,12 @@ qreal QCocoaWindow::devicePixelRatio() const
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- return qreal([[m_contentView window] backingScaleFactor]);
+ NSWindow* window = [m_contentView window];
+ if (window) {
+ return qreal([window backingScaleFactor]);
+ } else {
+ return 1.0;
+ }
} else
#endif
{