Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-15197

Try/Catch in reimplemented QApp::notify does not working on Mac OsX

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.5.0 Beta
    • 4.7.1
    • None
    • QT 4.7.0, 4.7.1, debug & release
    • macOS
    • 08cc9b9991ae9ab51bed5b857b6257401401ff6f

    Description

      I can not catch top level exceptions in Mac OsX. There are no problem in Windows.

      There is my code:

      class App: public QApplication{
      public:
      ...
          bool notify(QObject *o, QEvent *e){
              try
              {
                      return QApplication::notify(o, e);
              }
              catch(...){
                  QMessageBox::information(0,tr("Error"),tr("Press OK to continue."));
              }
          }
      }
      
      int main(int argc, char *argv[])
      {
          App a(argc, argv);
          try{
             MainWindow w;
             w.resize(900,700);
             w.show();
      
            return a.exec();
          }catch(..){
              QMessageBox::information(0,"Critical error","Press OK to close program");
           }
      }
      

      I send throw an exception in MainWindow.
      I see "Error" message with continue on Windows platform, but on Mac OsX I see only Critical Error without continue.

      On MacOs in debug output I see the message from QT:
      "Qt has caught an exception thrown from an event handler. Throwing
      exceptions from an event handler is not supported in Qt. You must
      reimplement QApplication::notify() and catch all exceptions there."

      But I already do it.

      Attachments

        1. main.cpp
          1 kB
        2. QtBug-15197.pro
          0.2 kB
        For Gerrit Dashboard: QTBUG-15197
        # Subject Branch Project Status CR V

        Activity

          People

            tpochep Timur Pocheptsov
            cemehehko Andrew Semenenko
            Votes:
            2 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes