Patch: Crash: blocking JS alert and deleting a window
Koos Vriezen
koos.vriezen at xs4all.nl
Fri Oct 18 13:48:42 BST 2002
Oops, only the last test case. And I forgot to delete 'dlgs' in the patch
Koos
On Fri, 18 Oct 2002, Koos Vriezen wrote:
> Hi,
>
> The crashes with the test cases below, can be fixed by closing all dialogs
> of this view before doing a 'Window::DelayedAction( Window::DelayedClose )'
>
RCS file: /home/kde/kdelibs/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.277
diff -u -3 -p -r1.277 kjs_window.cpp
--- ecma/kjs_window.cpp 2002/10/07 15:57:33 1.277
+++ ecma/kjs_window.cpp 2002/10/18 12:43:58
@@ -32,6 +32,7 @@
#include <kconfig.h>
#include <assert.h>
#include <qstyle.h>
+#include <qobjectlist.h>
#include <kjs/collector.h>
#include "kjs_proxy.h"
@@ -1336,6 +1337,13 @@ Value WindowFunc::tryCall(ExecState *exe
// then schedule a delayed close (so that the script terminates first).
// But otherwise, close immediately. This fixes w=window.open("","name");w.close();window.open("name");
if ( Window::retrieveActive(exec) == window ) {
+ if (widget) {
+ // quit all modal dialogs of this view
+ QObjectList *dlgs = widget->topLevelWidget()->queryList("QDialog");
+ for (QObject *dlg = dlgs->first(); dlg; dlg = dlgs->next())
+ static_cast<QDialog*>(dlg)->hide();
+ delete dlgs;
+ }
// We'll close the window at the end of the script execution
Window* w = const_cast<Window*>(window);
w->m_delayed.append( Window::DelayedAction( Window::DelayedClose ) );
>
> Is this correct?
>
> Regards,
>
> Koos
>
> On Sat, 5 Oct 2002, Koos Vriezen wrote:
> >
> > There are other cases, eg calls to Java, that could block JS. Something
> > has to be done.
> > That khtml currently even self doesn't check if it can close the window
> > proves the next testcase
> >
> > <html><head><script>
> > var win=open("", "xxx");
> > var doc=win.document;
> > doc.open();
> >
> > doc.write("<html><script>setTimeout('self.close()',1000);alert(somevar);<\/script><body>");
> > doc.write("</body></html>");
> > doc.close();
> > </script></head>
> > <body></body></html>
> >
> > Crash with backtrace this time.
More information about the kfm-devel
mailing list