Patch: Crash: blocking JS alert and deleting a window
David Faure
david at mandrakesoft.com
Fri Oct 18 13:41:15 BST 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 18 October 2002 14:33, Koos Vriezen wrote:
> Index: ecma/kjs_window.cpp
> ===================================================================
> 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:24:24
> @@ -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,12 @@ 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())
> + ((QDialog*)dlg)->hide();
> + }
> // 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?
Looks good to me (maybe add a simplified testcase in comments, to
explain why this is needed, like I did 2 lines above).
I think this testcase does it: setTimeout('self.close()',1000); alert("Hi");
BTW the comment says "modal" and the code even closes non-modal dialogs,
but this obviously doesn't hurt (they would be destroyed when closing the window
anyway).
Thanks for having fixed this tricky problem :)
- --
David FAURE, david at mandrakesoft.com, faure at kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
Get the latest KOffice - http://download.kde.org/stable/koffice-1.2/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9sAFr72KcVAmwbhARAlm4AKCfmbZKkSUJI1iQAx26d03eK5mjigCgnMrv
fx4Iy7qcY/c9iEW6q+2PCJU=
=L4N7
-----END PGP SIGNATURE-----
More information about the kfm-devel
mailing list