summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-11-07 13:16:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-08 07:21:40 +0100
commitac7823129a529a71d2725fdeadc5eff7a2b0788a (patch)
tree3cb1a326dcd26f7eee7b19d5b383a52c10a375dc /src/plugins
parent59be0509e087a5d4a8884a56e14a2ddbf5735ac4 (diff)
iOS: Cancel any active touches when destroying a QIOSWindow
Keeps the internal state of QtGui sane when it comes to which buttons are active, etc. Change-Id: Ic63e74d2546469e085ec46b74f4cf159dd409b07 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 70f4cc4267..fa0519a37c 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -226,6 +226,9 @@
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
+ if (!touches && m_activeTouches.isEmpty())
+ return;
+
if (!touches) {
m_activeTouches.clear();
} else {
@@ -238,9 +241,11 @@
m_nextTouchId = 0;
+ NSTimeInterval timestamp = event ? event.timestamp : [[NSProcessInfo processInfo] systemUptime];
+
// Send cancel touch event synchronously
QIOSIntegration *iosIntegration = static_cast<QIOSIntegration *>(QGuiApplicationPrivate::platformIntegration());
- QWindowSystemInterface::handleTouchCancelEvent(m_qioswindow->window(), ulong(event.timestamp * 1000), iosIntegration->touchDevice());
+ QWindowSystemInterface::handleTouchCancelEvent(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice());
QWindowSystemInterface::flushWindowSystemEvents();
}
@@ -342,6 +347,13 @@ QIOSWindow::QIOSWindow(QWindow *window)
QIOSWindow::~QIOSWindow()
{
+ // According to the UIResponder documentation, Cocoa Touch should react to system interruptions
+ // that "might cause the view to be removed from the window" by sending touchesCancelled, but in
+ // practice this doesn't seem to happen when removing the view from its superview. To ensure that
+ // Qt's internal state for touch and mouse handling is kept consistent, we therefor have to force
+ // cancellation of all touch events.
+ [m_view touchesCancelled:0 withEvent:0];
+
[m_view removeFromSuperview];
[m_view release];
}