diff options
author | Norwegian Rock Cat <qt-info@nokia.com> | 2009-04-07 13:30:12 (GMT) |
---|---|---|
committer | Norwegian Rock Cat <qt-info@nokia.com> | 2009-04-07 13:35:47 (GMT) |
commit | 773c4d326c24f8db12ab58e379bd223ce1126d72 (patch) | |
tree | e8ccabf955901f8eb4e8de44d70bb7e1f84b0ef4 | |
parent | de007bd2a20a141aefe901408512c806879a2387 (diff) | |
download | Qt-773c4d326c24f8db12ab58e379bd223ce1126d72.zip Qt-773c4d326c24f8db12ab58e379bd223ce1126d72.tar.gz Qt-773c4d326c24f8db12ab58e379bd223ce1126d72.tar.bz2 |
BT: Prevent a crash in Designer when quiting when in the filter edit.
Gah, my original change (f5ef0eb1a6543abdd29e07c23de7fa1128f6d623) had
its heart in the right place, but it seems that it can cause crashes
on closing where we refuse to give up the first responder and we end up
with a dangling pointer. This lets that case happen (when we have no
focus widget and are setting a nil first responder, there's no reason to
stop that, but it refuses to do that when we do have a focus widget.
Hopefully we don't get in a situation where our focus widget gets out of
sync.
Reviewed-by: Prasanth Ullattil
-rw-r--r-- | src/gui/kernel/qcocoapanel_mac.mm | 5 | ||||
-rw-r--r-- | src/gui/kernel/qcocoawindow_mac.mm | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm index c17b30c..95e20af 100644 --- a/src/gui/kernel/qcocoapanel_mac.mm +++ b/src/gui/kernel/qcocoapanel_mac.mm @@ -157,10 +157,11 @@ QT_USE_NAMESPACE [self release]; } - - (BOOL)makeFirstResponder:(NSResponder *)responder { - if (responder == nil) + // For some reason Cocoa wants to flip the first responder + // when Qt doesn't want to, sorry, but "No" :-) + if (responder == nil && qApp->focusWidget()) return NO; return [super makeFirstResponder:responder]; } diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm index ba121cd..e7b76a7 100644 --- a/src/gui/kernel/qcocoawindow_mac.mm +++ b/src/gui/kernel/qcocoawindow_mac.mm @@ -182,7 +182,9 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview. - (BOOL)makeFirstResponder:(NSResponder *)responder { - if (responder == nil) + // For some reason Cocoa wants to flip the first responder + // when Qt doesn't want to, sorry, but "No" :-) + if (responder == nil && qApp->focusWidget()) return NO; return [super makeFirstResponder:responder]; } |