Patch: Crash: blocking JS alert and deleting a window

Koos Vriezen koos.vriezen at xs4all.nl
Fri Oct 18 22:18:06 BST 2002


On Fri, 18 Oct 2002, David Faure wrote:

> On Friday 18 October 2002 19:18, Koos Vriezen wrote:
> > On Fri, 18 Oct 2002, David Faure wrote:
> >
> > > But going up to the top-level-widget is too much, no?
> > > Imagine a splitted Konqueror window, two HTML views, one shows a dialog,
> > > the other one is aborted -> closeURL -> the dialog gets closed?
> >
> > Ok, I remove that....yes still no crashes.
> Good.
>
> > Was it ok in the
> > ecma/kjs_window patch (topLevelWidget I mean)?
> No, same problem there, I'd say.
>
> > (otherwise we might introduce a KHTMLView::closeChildDialogs())
> Sounds good.

Unfortunately removing topLevelWidget() in ecma/kjs_window makes
'setTimeout('self.close()',1000); alert("Hi");' crash again, better leave
it then (can JS close a frame?).

Ok, I could do:

--- khtmlview.h 2002/09/25 15:09:11     1.165
+++ khtmlview.h 2002/10/18 21:11:48
@@ -142,6 +142,11 @@ public:
      */
     void layout();

+    /**
+     * Close all child dialogs
+     **/
+    void closeChildDialogs();
+
 signals:
     void cleared();
     void zoomView( int );
--- khtmlview.cpp       2002/09/30 09:56:42     1.490
+++ khtmlview.cpp       2002/10/18 21:11:49
@@ -50,6 +50,7 @@
 #include <qtooltip.h>
 #include <qpainter.h>
 #include <qpaintdevicemetrics.h>
+#include <qobjectlist.h>
 #include <kapplication.h>

 #include <kimageio.h>
@@ -457,6 +458,14 @@ void KHTMLView::layout()
     } else {
         _width = visibleWidth();
     }
+}
+
+void KHTMLView::closeChildDialogs()
+{
+    QObjectList *dlgs = queryList("QDialog");
+    for (QObject *dlg = dlgs->first(); dlg; dlg = dlgs->next())
+        static_cast<QWidget*>(dlg)->close();
+    delete dlgs;
 }

 //
--- khtml_part.cpp      2002/10/17 17:23:12     1.755
+++ khtml_part.cpp      2002/10/18 21:11:52
@@ -540,6 +540,8 @@ bool KHTMLPart::closeURL()
   // null node activated.
   emit nodeActivated(Node());

+  d->m_view->closeChildDialogs();
+
   return true;
 }

or, since it used only once, like posted before:

--- khtml_part.cpp      2002/10/17 17:23:12     1.755
+++ khtml_part.cpp      2002/10/18 21:14:18
@@ -540,6 +540,11 @@ bool KHTMLPart::closeURL()
   // null node activated.
   emit nodeActivated(Node());

+  QObjectList *dlgs = d->m_view->queryList("QDialog");
+  for (QObject *dlg = dlgs->first(); dlg; dlg = dlgs->next())
+    static_cast<QDialog*>(dlg)->close();
+  delete dlgs;
+
   return true;
 }

If no further comments, I'll commit the last patch.

Koos





More information about the kfm-devel mailing list