iOS: Limit duration of FirstResponderCandidate to becomeFirstResponder

We only need the FirstResponderCandidate for the duration of the call to
[super becomeFirstResponder]. Keeping it around longer means that when
emitting window activation events, which may result in changing the
first responder again, we may wrongly conclude that we're not allowed
to change the responder due to the FirstResponderCandidate still being
alive.

Change-Id: I8203e795cdde4128776283fe63a1907eb6ebc151
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Tor Arne Vestbø 2017-01-03 17:50:28 +01:00
parent 8ad200dcb4
commit bc80cef1d4

View File

@ -209,19 +209,24 @@
- (BOOL)becomeFirstResponder
{
FirstResponderCandidate firstResponderCandidate(self);
{
// Scope for the duration of becoming first responder only, as the window
// activation event may trigger new responders, which we don't want to be
// blocked by this guard.
FirstResponderCandidate firstResponderCandidate(self);
qImDebug() << "win:" << m_qioswindow->window() << "self:" << self
<< "first:" << [UIResponder currentFirstResponder];
qImDebug() << "win:" << m_qioswindow->window() << "self:" << self
<< "first:" << [UIResponder currentFirstResponder];
if (![super becomeFirstResponder]) {
qImDebug() << m_qioswindow->window()
<< "was not allowed to become first responder";
return NO;
if (![super becomeFirstResponder]) {
qImDebug() << m_qioswindow->window()
<< "was not allowed to become first responder";
return NO;
}
qImDebug() << m_qioswindow->window() << "became first responder";
}
qImDebug() << m_qioswindow->window() << "became first responder";
if (qGuiApp->focusWindow() != m_qioswindow->window())
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window());
else