[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [patch] non-blocking messagebox.
From:       Olivier Goffart <ogoffart () tiscalinet ! be>
Date:       2003-09-14 12:17:26
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Often I already has some crash in my application due indirectly to an error 
message, or an information messagebox.

The problem is that calling a dialog with exec() call  
QApplication::enter_loop()  and it this loop, some components can be deleted, 
specialy the class which call the dialog. 

This could be the best way to fix bug like
Bug 63524 and Bug 63127

The patch add an option to the message box to cal QDialog::show() insteads of 
QDialog::exec()  Of course, this is only usefull if this is a simple error or 
information dialog, without exepting results

Opinions?

["kmessagebox.diff" (text/x-diff)]

? .new.kaboutapp
? kmessagebox.diff
Index: kmessagebox.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmessagebox.cpp,v
retrieving revision 1.83
diff -u -p -b -B -r1.83 kmessagebox.cpp
--- kmessagebox.cpp	13 Sep 2003 20:22:43 -0000	1.83
+++ kmessagebox.cpp	14 Sep 2003 11:51:01 -0000
@@ -274,6 +274,12 @@ static int createKMessageBox(KDialogBase
        return KMessageBox::Cancel; // We have to return something.
     }
     
+    if(options & KMessageBox::Noblocking )
+    {
+		QObject::connect(dialog, SIGNAL(finished()) , dialog, SLOT(delayedDestruct()));
+		dialog->show();
+		return 0;
+    }
     // We use a QGuardedPtr because the dialog may get deleted
     // during exec() if the parent of the dialog gets deleted.
     // In that case the guarded ptr will reset to 0.
Index: kmessagebox.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmessagebox.h,v
retrieving revision 1.50
diff -u -p -b -B -r1.50 kmessagebox.h
--- kmessagebox.h	13 Sep 2003 20:22:43 -0000	1.50
+++ kmessagebox.h	14 Sep 2003 11:51:01 -0000
@@ -69,13 +69,16 @@ public:
  /**
   * @li Notify Emit a KNotifyClient event (Not yet implemented)
   * @li AllowLink The message may contain links.
-  * @li Dangerous The action to be confirmed by the dialog is a potentially \
destructive one +  * @li Dangerous The action to be confirmed by the dialog is a \
potentially destructive one. (Used to make "No" the default button) +  * @li \
Noblocking The dialog does not block your code. (can't be used only if you don't \
                exept results)
   */
  enum OptionsType
  {
    Notify = 1,
    AllowLink = 2,
-   Dangerous = 4
+   Dangerous = 4,
+   Noblocking = 8 /// @since 3.2
+
  };
 
  /**


[Attachment #6 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic