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>
This commit is contained in:
Daiwei Li 2013-08-13 15:41:04 -07:00 committed by The Qt Project
parent 9194fc00a6
commit 79570157e3

View File

@ -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
{