Crash: blocking JS and deleting a window

Koos Vriezen koos.vriezen at xs4all.nl
Wed Oct 16 11:30:26 BST 2002


On Tue, 15 Oct 2002, Koos Vriezen wrote:

> On Fri, 11 Oct 2002, Maks Orlovich wrote:
>
> > #41 0x41b9f341 in KJS::Object::call () from /opt/kde-cvs/lib/libkjs.so.1
> > #42 0x41ae4c1d in KJS::JSEventListener::handleEvent ()
> [..]
> > #44 0x417a2e30 in DOM::NodeImpl::dispatchGenericEvent ()
> [..]
> > #47 0x417a037c in DOM::DocumentImpl::setFocusNode ()
> >    from /opt/kde-cvs/lib/libkhtml.so.4
> > #48 0x417703be in KHTMLView::focusNextPrevNode ()
> >    from /opt/kde-cvs/lib/libkhtml.so.4
> > #49 0x4176fb55 in KHTMLView::focusNextPrevChild ()
> > #50 0x4094c1f5 in QWidget::focusNextPrevChild (this=0x8347de0, next=true)
> [..]
> > #54 0x417f4a42 in khtml::RenderWidget::~RenderWidget ()
> [..]
> > #64 0x4179d369 in DOM::DocumentImpl::detach ()
>
> Hmmm, onBlur event while detaching. Either
> 'KHTMLView::focusNextPrevChild()' or 'DOM::DocumentImpl::setFocusNode()'
> should check if 'm_render' of document not is null.

Next patch fixes this case in DocumentImpl::setFocusNode:

--- xml/dom_docimpl.cpp 2002/09/24 02:24:06     1.195
+++ xml/dom_docimpl.cpp 2002/10/16 10:12:42
@@ -1870,6 +1870,8 @@ void DocumentImpl::recalcStyleSelector()

 void DocumentImpl::setFocusNode(NodeImpl *newFocusNode)
 {
+    // don't process focus changes while detaching
+    if( !m_render ) return;
     // Make sure newFocusNode is actually in this document
     if (newFocusNode && (newFocusNode->getDocument() != this))
         return;

If events never should occur in a not attached document, I think we should
go for this patch instead (and save some future headaches):

--- xml/dom_nodeimpl.cpp        2002/10/11 20:41:40     1.187
+++ xml/dom_nodeimpl.cpp        2002/10/16 10:12:43
@@ -702,6 +702,8 @@ bool NodeImpl::dispatchKeyEvent(QKeyEven

 void NodeImpl::handleLocalEvents(EventImpl *evt, bool useCapture)
 {
+    if (!getDocument() || !getDocument()->renderer())
+        return;
     if (!m_regdListeners)
         return;


Please comment if the second patch should not be applied.

Regards,

Koos





More information about the kfm-devel mailing list