Patch: Crash: blocking JS alert and deleting a window
Koos Vriezen
koos.vriezen at xs4all.nl
Sun Oct 20 13:59:55 BST 2002
Hi,
Attached the resulting patch which includes comments from David. Still not
sure weather to use hide(), enough to make the message loop end, or
close(), adviced by Harri but doesn't work in ecma/kjs_window, so I used
them both :)
Regards,
Koos
-------------- next part --------------
Index: khtmlview.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.h,v
retrieving revision 1.165
diff -u -3 -p -r1.165 khtmlview.h
--- khtmlview.h 2002/09/25 15:09:11 1.165
+++ khtmlview.h 2002/10/20 12:46:40
@@ -142,6 +142,11 @@ public:
*/
void layout();
+ /**
+ * Close all child dialogs
+ **/
+ void closeChildDialogs();
+
signals:
void cleared();
void zoomView( int );
Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.490
diff -u -3 -p -r1.490 khtmlview.cpp
--- khtmlview.cpp 2002/09/30 09:56:42 1.490
+++ khtmlview.cpp 2002/10/20 12:46:41
@@ -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;
}
//
Index: khtml_part.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
retrieving revision 1.756
diff -u -3 -p -r1.756 khtml_part.cpp
--- khtml_part.cpp 2002/10/19 15:15:01 1.756
+++ khtml_part.cpp 2002/10/20 12:46:44
@@ -540,6 +540,9 @@ bool KHTMLPart::closeURL()
// null node activated.
emit nodeActivated(Node());
+ // make sure clear() we pop out of a dialog's message loop
+ d->m_view->closeChildDialogs();
+
return true;
}
Index: ecma/kjs_window.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.279
diff -u -3 -p -r1.279 kjs_window.cpp
--- ecma/kjs_window.cpp 2002/10/19 15:21:07 1.279
+++ ecma/kjs_window.cpp 2002/10/20 12:46:45
@@ -1340,7 +1340,7 @@ Value WindowFunc::tryCall(ExecState *exe
if (widget) {
// quit all dialogs of this view
// this fixes 'setTimeout('self.close()',1000); alert("Hi");' crash
- QObjectList *dlgs = widget->topLevelWidget()->queryList("QDialog");
+ QObjectList *dlgs = widget->queryList("QDialog");
for (QObject *dlg = dlgs->first(); dlg; dlg = dlgs->next())
static_cast<QDialog*>(dlg)->hide();
delete dlgs;
More information about the kfm-devel
mailing list