diff options
author | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2016-01-11 11:27:19 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2016-01-11 18:30:42 +0000 |
commit | ca7f1d2197f78ec3332cfd86ab9921730b6d4f23 (patch) | |
tree | 093d2a79b2d90e5948e831b25733b593e17fd519 | |
parent | e8479592c5654e9ccc2f555f32db70e4d0b09ba9 (diff) | |
download | qtbase-ca7f1d2197f78ec3332cfd86ab9921730b6d4f23.tar.gz |
iOS: fix crash on iOS 8 due to unsupported selector
It turns out that f558bde was not enough to stop a crash when
trying to access forceTouchCapability of traitCollection. The
reason is that traitCollection is available on UIScreen starting
from iOS 8, while forceTouchCapability is available on
UITraitCollection starting from iOS 9. So only checking the former
will cause a crash when running on iOS 8.
Change-Id: I44f9fb785349694004fbf2f48fe3b85bb01d9a5a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
-rw-r--r-- | src/plugins/platforms/ios/qiosintegration.mm | 2 | ||||
-rw-r--r-- | src/plugins/platforms/ios/quiview.mm | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 3e6b5e51ea..85b5c477cc 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -105,7 +105,7 @@ QIOSIntegration::QIOSIntegration() m_touchDevice = new QTouchDevice; m_touchDevice->setType(QTouchDevice::TouchScreen); QTouchDevice::Capabilities touchCapabilities = QTouchDevice::Position | QTouchDevice::NormalizedPosition; - if ([mainScreen respondsToSelector:@selector(traitCollection)]) { + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) { if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) touchCapabilities |= QTouchDevice::Pressure; } diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 53b3d30327..4dd43be465 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -286,10 +286,14 @@ QTouchDevice *touchDevice = QIOSIntegration::instance()->touchDevice(); QTouchDevice::Capabilities touchCapabilities = touchDevice->capabilities(); - if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) - touchCapabilities |= QTouchDevice::Pressure; - else - touchCapabilities &= ~QTouchDevice::Pressure; + + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) { + if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) + touchCapabilities |= QTouchDevice::Pressure; + else + touchCapabilities &= ~QTouchDevice::Pressure; + } + touchDevice->setCapabilities(touchCapabilities); } |