Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Exception Triggered

Exception Triggered

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 628 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I think this may be down to the version of Qt being used, but I would like to know if there is a way of preventing this issue.

    In my main function I test for the command line arguments passed:

    void error(const char* cpszMsg) {
        perror(cpszMsg);
        QApplication::quit();
        exit(-1);
    }
    int main(int argc, char* argv[]) {
        if ( argc < 2 ) {
            error(static_cast<const char*>("Please specify configuration file!"));
        }
        Application a(arc, argue);
        MainWindow w;
        w.show();
        return a.exec();
    }
    

    This project is using Qt 5.9.2 and Microsoft Visual Studio 2015 32bit. The versions of Qt and MSVC are required by the application and company I am contracted to.

    When launching the application without any command line arguments to test I can see the error handler is triggered however following this is an Exception Triggered dialog containing:

    The inferior stopped because it triggered an exception.
    
    Stopped in thread 0 by: Exception at 0x7706de63, code: 0xc000005: read access violation at 0x0, flags = 0x0 (first chance).
    

    This doesn't happen on later versions of Qt, is there any way to prevent this dialog from being displayed on this version of Qt ?

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by
      #2

      I am wondering what is the outcome of QApplication::quit if no QApplication has been started...

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      SPlattenS 1 Reply Last reply
      0
      • JohanSoloJ JohanSolo

        I am wondering what is the outcome of QApplication::quit if no QApplication has been started...

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @JohanSolo , I've tried numerous permutations, with and without QApplication::quit, also with and without exit, just returning -1 from main.

        All result in the same dialog appearing.

        Kind Regards,
        Sy

        KroMignonK 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @SPlatten said in Exception Triggered:

          also with and without exit, just returning -1 from main.

          So you say that

          int main(int argc, char* argv[]) {
              if ( argc < 2 ) {
                  return -1;
              }
              QApplication a(arc, argv);
              return a.exec();
          }
          

          crashes also?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          SPlattenS 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @JohanSolo , I've tried numerous permutations, with and without QApplication::quit, also with and without exit, just returning -1 from main.

            All result in the same dialog appearing.

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by
            #5

            @SPlatten I guess the problem is that you try to destroy a QApplication which doesn't exists:

            void error(const char* cpszMsg) {
                perror(cpszMsg);
                if(qApp)
                    QApplication::quit();
                exit(-1);
            }
            

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            SPlattenS 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @SPlatten said in Exception Triggered:

              also with and without exit, just returning -1 from main.

              So you say that

              int main(int argc, char* argv[]) {
                  if ( argc < 2 ) {
                      return -1;
                  }
                  QApplication a(arc, argv);
                  return a.exec();
              }
              

              crashes also?

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #6

              @Christian-Ehrlicher , It doesn't crash, but when the application terminates the dialog is displayed.

              Kind Regards,
              Sy

              1 Reply Last reply
              0
              • KroMignonK KroMignon

                @SPlatten I guess the problem is that you try to destroy a QApplication which doesn't exists:

                void error(const char* cpszMsg) {
                    perror(cpszMsg);
                    if(qApp)
                        QApplication::quit();
                    exit(-1);
                }
                
                SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by
                #7

                @KroMignon I think this could be an issue with the Qt 5.9 SDK, because on later versions it does not do the same.

                Kind Regards,
                Sy

                SPlattenS 1 Reply Last reply
                0
                • SPlattenS SPlatten

                  @KroMignon I think this could be an issue with the Qt 5.9 SDK, because on later versions it does not do the same.

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #8

                  Ok, this behaviour only happens when running in debug mode in Qt Creator, when running outside of Qt Creator it does not do this, again, this seems specific to the SDK. This doesn't happen in newer versions of the SDK.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved