Patch: Crash: blocking JS alert and deleting a window

David Faure david at mandrakesoft.com
Thu Oct 24 10:57:41 BST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 24 October 2002 11:12, David Faure wrote:
> * a big switch depending on mEscapeButton (11 "case"s).
Not 11 in fact, since many buttons don't make sense as escape buttons
(since they don't close the dialog).

Here's a patch for this solution. Much easier to understand and follow in a debugger,
much more predictable, but it reimplements some logic that's already somewhere else
in KDialogBase.

Index: kdialogbase.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kdialogbase.cpp,v
retrieving revision 1.72
diff -u -p -b -r1.72 kdialogbase.cpp
- --- kdialogbase.cpp     2002/08/08 22:50:18     1.72
+++ kdialogbase.cpp     2002/10/24 09:54:16
@@ -1532,6 +1532,35 @@ void KDialogBase::closeEvent( QCloseEven
     }
 }

+void KDialogBase::cancel()
+{
+    switch ( mEscapeButton ) {
+    case Ok:
+        slotOk();
+        break;
+    case User1: // == No
+        if ( mMessageBoxMode )
+            slotNo();
+        else
+            slotUser1();
+        break;
+    case User2: // == Yes
+        if ( mMessageBoxMode )
+            slotYes();
+        else
+            slotUser2();
+        break;
+    case User3:
+        slotUser3();
+        break;
+    case Close:
+        slotClose();
+        break;
+    case Cancel:
+    default:
+       slotCancel();
+    }
+}

 bool KDialogBase::haveBackgroundTile()
 {


Rest of the patch unchanged, except that I also changed kjs_window.cpp to call
widget->closeChildDialogs() too (see, I was right to say that the method would end
up being called from more than one place ;)

Patch tested against the kjs_window.cpp testcase, and http://zip.to/reboot (#49068),
I'll commit later today if there's no objection.

- -- 
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)

iD8DBQE9t8QV72KcVAmwbhARAkB1AJ0Ql1IiKV7IUmT4jANqmmz/JdDFQQCeOH8X
aKQ+HW+xylS4+4UxXVBJ9Jo=
=AK76
-----END PGP SIGNATURE-----





More information about the kfm-devel mailing list