From 5949c215bd53582d0c6481f606a9ec015f067b37 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 18 Feb 2011 10:19:58 +0100 Subject: Cocoa: fix crash when using a drawer with a focus widget The crash happends when you close down an application that has a drawer that contains a widget with keyboard focus. The NSView backing this widget is then the first responder in Cocoa. This bug was a bit more hard-boiled than usual, and I can't say I truly understand whats going on. My findings are that both the drawer and the parent window both points to the same view inside the drawer as its first responder. And when deleting the drawer (togheter with the focus widget), the parent window is left pointing to a first responder that is actually deleted. Is seems that us refusing to release a view as first responder if we have no attached widget is wrong. So we choose to return YES instead, which after all makes much more sense. Task-number: QTBUG-15897 Reviewed-by: msorvig --- src/gui/kernel/qcocoaview_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 749472a..d9f428c 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -1115,7 +1115,7 @@ static int qCocoaViewCount = 0; - (BOOL)resignFirstResponder { if (!qwidget) - return NO; + return YES; // Seems like the following test only triggers if this // view is inside a QMacNativeWidget: if (qwidget == QApplication::focusWidget()) -- cgit v0.12