<rdar://problem/
3907484> REGRESSION (125-173): crash when KWQTextField is dealloc'ed while setting focus (profoundlearning.com)
* kwq/KWQWidget.mm:
(QWidget::setFocus): Handle the case where setting focus removed
us from the superview - this can happen due to style changes on
focus change.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8191
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-12-10 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Richard.
+
+ <rdar://problem/3907484> REGRESSION (125-173): crash when KWQTextField is dealloc'ed while setting focus (profoundlearning.com)
+
+ * kwq/KWQWidget.mm:
+ (QWidget::setFocus): Handle the case where setting focus removed
+ us from the superview - this can happen due to style changes on
+ focus change.
+
2004-12-10 Ken Kocienda <kocienda@apple.com>
Reviewed by Hyatt
KWQ_BLOCK_EXCEPTIONS;
if ([view acceptsFirstResponder]) {
- [KWQKHTMLPart::bridgeForWidget(this) makeFirstResponder:view];
+ WebCoreBridge *bridge = KWQKHTMLPart::bridgeForWidget(this);
+ NSResponder *oldFirstResponder = [bridge firstResponder];
+
+ [bridge makeFirstResponder:view];
+
+ // setting focus can actually cause a style change which might
+ // remove the view from its superview while it's being made
+ // first responder. This confuses AppKit so we must restore
+ // the old first responder.
+
+ if (![view superview]) {
+ [bridge makeFirstResponder:oldFirstResponder];
+ }
}
KWQ_UNBLOCK_EXCEPTIONS;
}