From 9d0181f0f740a2c07ff4141f60095c1d7710afee Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 8 Jan 2016 12:01:19 +0100 Subject: windows: bump OpenGL blacklist version Change-Id: If27c36de850b55907143e2b8a412fa8ac458fe97 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/openglblacklists/default.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index 2672711d3a..767eac161c 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -1,6 +1,6 @@ { "name": "Qt built-in GPU driver blacklist", - "version": "5.5", + "version": "5.6", "entries": [ { "id": 1, -- cgit v1.2.3 From 1bcfc3de7586ddb9f5d1b778b97b26ae3dc9584d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 6 Jan 2016 11:01:39 +0100 Subject: Use backing store formats with alpha We depend on being able to punch holes in the backing store when integrating with FBO elements. To do that we need a format with an alpha channel. This was only working previously because RGB32 didn't mask when filling or when converting to ARGB32_PM, but other formats didn't. Also unifies the logic for getting alpha versions of QImage formats. Task-number: QTBUG-50281 Change-Id: Ied1325f60e2b67d9ea2dfa9701b06fc2231ebfca Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 1825a463d0..006df320fe 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -172,6 +173,9 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI qWarning() << "QXcbBackingStore: Error while marking the shared memory segment to be destroyed"; } + if (QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::IgnoresAlpha) + format = qt_alphaVersionForPainting(format); + m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format); m_graphics_buffer = new QXcbShmGraphicsBuffer(&m_qimage); } -- cgit v1.2.3 From f8301029183a0ff653243d932b135405adee20b0 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 24 Dec 2015 13:35:40 +0300 Subject: xcb: Remove QXcbScreen::m_nativeGeometry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is equal to m_geometry since c173a5071906867de9da26ee8f49224b23c2ef1d (Remove QT_DEVICE_PIXEL_RATIO support from xcb). Also remove the declaration for QXcbWindow::screenForNativeGeometry(), which was forgotten to be removed in that commit. Change-Id: I8ec425a3bc111ec579e2e25c4fda8a02f1c8d09c Reviewed-by: Błażej Szczygieł Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/xcb/qxcbscreen.cpp | 13 ++++--------- src/plugins/platforms/xcb/qxcbscreen.h | 2 -- src/plugins/platforms/xcb/qxcbwindow.h | 1 - 3 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index caddd2b2a5..f3d381b99e 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -70,7 +70,7 @@ QXcbVirtualDesktop::~QXcbVirtualDesktop() QXcbScreen *QXcbVirtualDesktop::screenAt(const QPoint &pos) const { foreach (QXcbScreen *screen, connection()->screens()) { - if (screen->virtualDesktop() == this && screen->nativeGeometry().contains(pos)) + if (screen->virtualDesktop() == this && screen->geometry().contains(pos)) return screen; } return Q_NULLPTR; @@ -198,17 +198,15 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe } else if (xineramaScreenInfo) { m_geometry = QRect(xineramaScreenInfo->x_org, xineramaScreenInfo->y_org, xineramaScreenInfo->width, xineramaScreenInfo->height); - m_nativeGeometry = m_geometry; m_availableGeometry = m_geometry & m_virtualDesktop->workArea(); m_sizeMillimeters = sizeInMillimeters(m_geometry.size(), virtualDpi()); if (xineramaScreenIdx > -1) m_outputName += QLatin1Char('-') + QString::number(xineramaScreenIdx); } - if (m_geometry.isEmpty()) { + if (m_geometry.isEmpty()) m_geometry = QRect(QPoint(), m_virtualSize); - m_nativeGeometry = QRect(QPoint(), m_virtualSize); - } + if (m_availableGeometry.isEmpty()) m_availableGeometry = m_geometry; @@ -557,7 +555,6 @@ void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation) qreal dpi = xGeometry.width() / physicalSize().width() * qreal(25.4); m_pixelDensity = qRound(dpi/96); m_geometry = QRect(xGeometry.topLeft(), xGeometry.size()); - m_nativeGeometry = QRect(xGeometry.topLeft(), xGeometry.size()); m_availableGeometry = xGeometry & m_virtualDesktop->workArea(); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); } @@ -828,9 +825,7 @@ QDebug operator<<(QDebug debug, const QXcbScreen *screen) debug << ", screenNumber=" << screen->screenNumber(); debug << ", virtualSize=" << screen->virtualSize().width() << 'x' << screen->virtualSize().height() << " ("; formatSizeF(debug, screen->virtualSize()); - debug << "), nativeGeometry="; - formatRect(debug, screen->nativeGeometry()); - debug << ", orientation=" << screen->orientation(); + debug << "), orientation=" << screen->orientation(); debug << ", depth=" << screen->depth(); debug << ", refreshRate=" << screen->refreshRate(); debug << ", root=" << hex << screen->root(); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index dd7396aca2..f4de2b9dfd 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -114,7 +114,6 @@ public: QWindow *topLevelAt(const QPoint &point) const Q_DECL_OVERRIDE; QRect geometry() const Q_DECL_OVERRIDE { return m_geometry; } - QRect nativeGeometry() const { return m_nativeGeometry; } QRect availableGeometry() const Q_DECL_OVERRIDE {return m_availableGeometry;} int depth() const Q_DECL_OVERRIDE { return screen()->root_depth; } QImage::Format format() const Q_DECL_OVERRIDE; @@ -186,7 +185,6 @@ private: QSizeF m_outputSizeMillimeters; QSizeF m_sizeMillimeters; QRect m_geometry; - QRect m_nativeGeometry; QRect m_availableGeometry; QSize m_virtualSize; QSizeF m_virtualSizeMillimeters; diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 69c0819959..3cfa71c9e0 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -167,7 +167,6 @@ public: virtual void create(); virtual void destroy(); - QXcbScreen *screenForNativeGeometry(const QRect &newGeometry) const; public Q_SLOTS: void updateSyncRequestCounter(); -- cgit v1.2.3 From 644441eed3997bc8cf7cfe5b4f56adee6e232ffd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 8 Jan 2016 17:12:50 +0100 Subject: Windows: Output resulting DPI awareness in debug and warning output. Fix the signature of QWindowsShcoreDLL::GetProcessDpiAwareness and output the value in the warning about failures of SetProcessDpiAwareness and in debug output. Failures occur when Qt is embedded into another application, for example Active Qt servers. Task-number: QTBUG-41186 Task-number: QTBUG-50206 Change-Id: I3fd6cba26826ee8bbfa0a34f129deb64797c947f Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowscontext.cpp | 19 +++++++++++++++++-- src/plugins/platforms/windows/qwindowscontext.h | 3 ++- src/plugins/platforms/windows/qwindowsintegration.cpp | 3 ++- 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index f2f6402889..4934b6c6e4 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -405,14 +405,29 @@ void QWindowsContext::setTabletAbsoluteRange(int a) #endif } +int QWindowsContext::processDpiAwareness() +{ +#ifndef Q_OS_WINCE + int result; + if (QWindowsContext::shcoredll.getProcessDpiAwareness + && SUCCEEDED(QWindowsContext::shcoredll.getProcessDpiAwareness(NULL, &result))) { + return result; + } +#endif // !Q_OS_WINCE + return -1; +} + void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness) { #ifndef Q_OS_WINCE qCDebug(lcQpaWindows) << __FUNCTION__ << dpiAwareness; if (QWindowsContext::shcoredll.isValid()) { const HRESULT hr = QWindowsContext::shcoredll.setProcessDpiAwareness(dpiAwareness); - if (FAILED(hr)) - qWarning() << "SetProcessDpiAwareness failed:" << QWindowsContext::comErrorString(hr); + if (FAILED(hr)) { + qWarning().noquote().nospace() << "SetProcessDpiAwareness(" + << dpiAwareness << ") failed: " << QWindowsContext::comErrorString(hr) + << ", using " << QWindowsContext::processDpiAwareness(); + } } else { if (dpiAwareness != QtWindows::ProcessDpiUnaware && QWindowsContext::user32dll.setProcessDPIAware) { if (!QWindowsContext::user32dll.setProcessDPIAware()) diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index d08fc8f726..14baec96d8 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -148,7 +148,7 @@ struct QWindowsShcoreDLL { void init(); inline bool isValid() const { return getProcessDpiAwareness && setProcessDpiAwareness && getDpiForMonitor; } - typedef HRESULT (WINAPI *GetProcessDpiAwareness)(HANDLE,int); + typedef HRESULT (WINAPI *GetProcessDpiAwareness)(HANDLE,int *); typedef HRESULT (WINAPI *SetProcessDpiAwareness)(int); typedef HRESULT (WINAPI *GetDpiForMonitor)(HMONITOR,int,UINT *,UINT *); @@ -219,6 +219,7 @@ public: void setTabletAbsoluteRange(int a); void setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness); + static int processDpiAwareness(); // Returns a combination of SystemInfoFlags unsigned systemInfo() const; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 55e6d55e5b..bd2014b8f2 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -224,7 +224,8 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL dpiAwarenessSet = true; } qCDebug(lcQpaWindows) - << __FUNCTION__ << "DpiAwareness=" << dpiAwareness; + << __FUNCTION__ << "DpiAwareness=" << dpiAwareness + << "effective process DPI awareness=" << QWindowsContext::processDpiAwareness(); m_context.initTouch(m_options); } -- cgit v1.2.3 From 2b1f01426c1ee47474b4b8e4e53799d992d0711c Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 7 Jan 2016 13:20:08 +0100 Subject: WinRT: Fix application shutdown Do not create a dummy eglDisplay when the global static is constructed. This causes ANGLE to wrongly set some internals, which breaks usage of EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE as the attribute map might be empty after calling eglGetPlatformDisplayEXT. Furthermore initialize() assigns a new display to it without terminating the old one. This way, the internal suspend handler in ANGLE (Trim11.cpp) will be added to the application. The suspend handler is not invoked when an application suspends though. Reason being that the handler needs to be added from inside the Xaml thread. As we cannot control this inside ANGLE, we will call eglInitialize inside the Xaml thread and hence get the suspend event properly. Task-number: QTBUG-50337 Task-number: QTBUG-50292 Change-Id: I3867377254c37084bf24f18e78af467f6237db57 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrteglcontext.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp index 3fd0278360..ebd15d7184 100644 --- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp @@ -54,9 +54,6 @@ QT_BEGIN_NAMESPACE struct WinRTEGLDisplay { WinRTEGLDisplay() { - eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (eglDisplay == EGL_NO_DISPLAY) - qCritical("Failed to initialize EGL display: 0x%x", eglGetError()); } ~WinRTEGLDisplay() { eglTerminate(eglDisplay); @@ -117,9 +114,17 @@ void QWinRTEGLContext::initialize() if (g->eglDisplay == EGL_NO_DISPLAY) qCritical("Failed to initialize EGL display: 0x%x", eglGetError()); - if (!eglInitialize(g->eglDisplay, nullptr, nullptr)) - qCritical("Failed to initialize EGL: 0x%x", eglGetError()); - + // eglInitialize checks for EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE + // which adds a suspending handler. This needs to be added from the Xaml + // thread itself, otherwise it will not be invoked. add_Suspending does + // not return an error unfortunately, so it silently fails and causes + // applications to not quit when the system wants to terminate the app + // after suspend. + hr = QEventDispatcherWinRT::runOnXamlThread([]() { + if (!eglInitialize(g->eglDisplay, nullptr, nullptr)) + qCritical("Failed to initialize EGL: 0x%x", eglGetError()); + return S_OK; + }); d->eglConfig = q_configFromGLFormat(g->eglDisplay, d->format); const EGLint flags = d->format.testOption(QSurfaceFormat::DebugContext) -- cgit v1.2.3 From c4ecab7127807eddd820b5c747a805cf5b0fd06d Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 7 Jan 2016 13:32:09 +0100 Subject: WinRT: Invoke correct remove handler Probably a typo when moving to Xaml. Change-Id: I0739f4561912e1e16df7b124d6d187cd0f60f657 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp index e94a0aa846..93757d293c 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.cpp +++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp @@ -124,7 +124,7 @@ QWinRTIntegration::QWinRTIntegration() : d_ptr(new QWinRTIntegrationPrivate) IID_PPV_ARGS(&d->application)); Q_ASSERT_SUCCEEDED(hr); hr = d->application->add_Suspending(Callback(this, &QWinRTIntegration::onSuspended).Get(), - &d->applicationTokens[&ICoreApplication::remove_Resuming]); + &d->applicationTokens[&ICoreApplication::remove_Suspending]); Q_ASSERT_SUCCEEDED(hr); hr = d->application->add_Resuming(Callback(this, &QWinRTIntegration::onResume).Get(), &d->applicationTokens[&ICoreApplication::remove_Resuming]); -- cgit v1.2.3 From becbffe291c1105eb422e8dc66c67c5b6443b96c Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 8 Jan 2016 12:50:32 +0100 Subject: winphone: Properly close the application When shutting down an application on Windows Phone the SceneGraph tries to create an offscreen surface to render into. If there is no offscreen surface available, it creates a new native window and tries to hide it. As the native event loop is about to shut down, creation fails and exceptions are raised. Instead we create a vanilla QPlatformOffscreenSurface. The SceneGraph recognizes it as such and can handle a proper cleanup on its own. Furthermore removing the suspend/resume handler in the destructor of QWinRTIntegration fails for Windows Phone as the application object itself does not accept this anymore. Hence skip this part for this platform. Task-number: QTBUG-49310 Change-Id: I02acdd5a635ef0b9d6ef8199376537b8f0f1a8fb Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrteglcontext.cpp | 4 ++++ src/plugins/platforms/winrt/qwinrtintegration.cpp | 17 +++++++++++++++++ src/plugins/platforms/winrt/qwinrtintegration.h | 1 + 3 files changed, 22 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp index ebd15d7184..bc77df566e 100644 --- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp @@ -46,6 +46,7 @@ #define EGL_EGLEXT_PROTOTYPES #include +#include #include #include @@ -147,6 +148,9 @@ bool QWinRTEGLContext::makeCurrent(QPlatformSurface *windowSurface) Q_D(QWinRTEGLContext); Q_ASSERT(windowSurface->surface()->supportsOpenGL()); + if (windowSurface->surface()->surfaceClass() == QSurface::Offscreen) + return false; + QWinRTWindow *window = static_cast(windowSurface); if (window->eglSurface() == EGL_NO_SURFACE) window->createEglSurface(g->eglDisplay, d->eglConfig); diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp index 93757d293c..71e92f33ca 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.cpp +++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp @@ -49,6 +49,8 @@ #include #include +#include + #include #include #include @@ -180,10 +182,15 @@ QWinRTIntegration::~QWinRTIntegration() Q_ASSERT_SUCCEEDED(hr); } #endif + // Do not execute this on Windows Phone as the application is already + // shutting down and trying to unregister suspending/resume handler will + // cause exceptions and assert in debug mode +#ifndef Q_OS_WINPHONE for (QHash::const_iterator i = d->applicationTokens.begin(); i != d->applicationTokens.end(); ++i) { hr = (d->application.Get()->*i.key())(i.value()); Q_ASSERT_SUCCEEDED(hr); } +#endif destroyScreen(d->mainScreen); Windows::Foundation::Uninitialize(); } @@ -349,4 +356,14 @@ HRESULT QWinRTIntegration::onResume(IInspectable *, IInspectable *) return S_OK; } +QPlatformOffscreenSurface *QWinRTIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const +{ + // This is only used for shutdown of applications. + // In case we do not return an empty surface the scenegraph will try + // to create a new native window during application exit causing crashes + // or assertions. + return new QPlatformOffscreenSurface(surface); +} + + QT_END_NAMESPACE diff --git a/src/plugins/platforms/winrt/qwinrtintegration.h b/src/plugins/platforms/winrt/qwinrtintegration.h index 5456f6922f..31a3ce7c1c 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.h +++ b/src/plugins/platforms/winrt/qwinrtintegration.h @@ -98,6 +98,7 @@ public: QStringList themeNames() const Q_DECL_OVERRIDE; QPlatformTheme *createPlatformTheme(const QString &name) const Q_DECL_OVERRIDE; + QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE; private: #ifdef Q_OS_WINPHONE HRESULT onBackButtonPressed(IInspectable *, ABI::Windows::Phone::UI::Input::IBackPressedEventArgs *args); -- cgit v1.2.3 From 0355345398ab1bfc46d56ebab7afbb91afc74ee4 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 8 Jan 2016 18:08:36 +0100 Subject: winrt: Flush the system event queue when adding/removing windows This has only been identified by WACK for Windows 10. QWinRTWindow::setVisible adds a Window to the screen and immediately tries to set the native visibility. This only works when the system events are handled immediately. While this is the case most of the time, certification tests revealed that this is not always the case. We have to flush before setting the element visibility. Change-Id: Ifce4c045c185c57bc386a4e832074fb84f5d0053 Reviewed-by: Andrew Knight Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index a642443386..997aa0d86c 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -779,6 +779,7 @@ void QWinRTScreen::addWindow(QWindow *window) d->visibleWindows.prepend(window); QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason); handleExpose(); + QWindowSystemInterface::flushWindowSystemEvents(); } void QWinRTScreen::removeWindow(QWindow *window) @@ -796,6 +797,7 @@ void QWinRTScreen::removeWindow(QWindow *window) if (wasTopWindow) QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason); handleExpose(); + QWindowSystemInterface::flushWindowSystemEvents(); } void QWinRTScreen::raise(QWindow *window) -- cgit v1.2.3 From ca7f1d2197f78ec3332cfd86ab9921730b6d4f23 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 11 Jan 2016 11:27:19 +0100 Subject: iOS: fix crash on iOS 8 due to unsupported selector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/plugins/platforms/ios/qiosintegration.mm | 2 +- src/plugins/platforms/ios/quiview.mm | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/plugins') 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); } -- cgit v1.2.3