Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Catch exceptions in QT/C++ (QGuiApplication) (override notify() method?)

Catch exceptions in QT/C++ (QGuiApplication) (override notify() method?)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
13 Posts 3 Posters 4.0k 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.
  • S Offline
    S Offline
    sierdzio
    Moderators
    wrote on 23 Jun 2022, 04:57 last edited by
    #2

    I don't know if this has anything to do with the crash, but your DebugApplication lacks Q_OBJECT macro.

    (Z(:^

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Jun 2022, 18:58 last edited by
      #3

      Hi and welcome to devnet,

      You constructor signature is wrong.

      argc must be a reference to an int not an int.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      K 1 Reply Last reply 23 Jun 2022, 22:22
      3
      • S SGaist
        23 Jun 2022, 18:58

        Hi and welcome to devnet,

        You constructor signature is wrong.

        argc must be a reference to an int not an int.

        K Offline
        K Offline
        komodosp
        wrote on 23 Jun 2022, 22:22 last edited by
        #4

        @SGaist

        Thanks! Well that got me past that problem, my application is now running!

        However, overriding the notify() method did nothing... My application still crashes at the exception code without an error message if I run in Release mode.

        In debug mode I get this, which is what I'd expect

        ASSERT failure in QList<T>::operator[]: "index out of range", file /opt/ti/processor-sdk-linux-am335x-evm-04.03.00.05/linux-devkit/sysroots/armv7ahf-neon-linux-gnueabi/usr/include/qt5/QtCore/qlist.h, line 545
        Process killed by signal

        But in release mode just

        Process killed by signal

        Code to cause exception is:

        QStringList stringlist {"hello"};
        qDebug() << "String 2 is " << stringlist[2];
        

        .. and it's in a backend handler for a QML splash screen.

        (Not sure if I should make this another question or not)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 24 Jun 2022, 07:03 last edited by
          #5

          Qt does not raise exceptions, so you cannot catch them.

          (Z(:^

          1 Reply Last reply
          3
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 24 Jun 2022, 07:51 last edited by
            #6

            To add to @sierdzio, you are encountering an assert which is not the same as an exception. In your case, you are not entering a potential runtime error, it's clearly a bug that you have to fix in your code.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • K Offline
              K Offline
              komodosp
              wrote on 24 Jun 2022, 15:12 last edited by
              #7

              Right - thanks for the info guys...

              So it doesn't raise exceptions, but does it do anything when the application crashes that could be used to determine what happened?

              I accept might be a bug in the code, unfortunately at the moment I'm at a loss to find where it is as it seems to happen randomly and rarely, and with seemingly no pattern.

              S 1 Reply Last reply 27 Jun 2022, 08:15
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 24 Jun 2022, 19:36 last edited by
                #8

                Do you have a lot of containers in your application ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                K 1 Reply Last reply 26 Jun 2022, 16:18
                0
                • S SGaist
                  24 Jun 2022, 19:36

                  Do you have a lot of containers in your application ?

                  K Offline
                  K Offline
                  komodosp
                  wrote on 26 Jun 2022, 16:18 last edited by
                  #9

                  @SGaist Do you mean like list type objects as described here? https://wiki.qt.io/QML_Containers

                  ...then yeah I do have quite a lot, esp. QList and QVector

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 26 Jun 2022, 18:59 last edited by
                    #10

                    From the crash we know it's one of the QList access that is at fault. Are you doing unchecked access in some specific files ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    K 1 Reply Last reply 26 Jun 2022, 20:58
                    0
                    • S SGaist
                      26 Jun 2022, 18:59

                      From the crash we know it's one of the QList access that is at fault. Are you doing unchecked access in some specific files ?

                      K Offline
                      K Offline
                      komodosp
                      wrote on 26 Jun 2022, 20:58 last edited by
                      #11

                      @SGaist Ahh - maybe I didn't explain myself properly. The Assert failure error message that I put in the message above was actually just a result of my attempt to cause an exception or error message to appear or be logged, so I can have it in place to diagnose the "real" error when it occurs. That could be something different but at the moment the application is just dying.

                      K 1 Reply Last reply 26 Jun 2022, 21:39
                      0
                      • K komodosp
                        26 Jun 2022, 20:58

                        @SGaist Ahh - maybe I didn't explain myself properly. The Assert failure error message that I put in the message above was actually just a result of my attempt to cause an exception or error message to appear or be logged, so I can have it in place to diagnose the "real" error when it occurs. That could be something different but at the moment the application is just dying.

                        K Offline
                        K Offline
                        komodosp
                        wrote on 26 Jun 2022, 21:39 last edited by
                        #12

                        @komodosp
                        Should this code be generating a core dump? Can't even find that....

                        QStringList stringlist {"hello"};
                        qDebug() << "String 2 is " << stringlist[2];
                        
                        1 Reply Last reply
                        0
                        • K komodosp
                          24 Jun 2022, 15:12

                          Right - thanks for the info guys...

                          So it doesn't raise exceptions, but does it do anything when the application crashes that could be used to determine what happened?

                          I accept might be a bug in the code, unfortunately at the moment I'm at a loss to find where it is as it seems to happen randomly and rarely, and with seemingly no pattern.

                          S Offline
                          S Offline
                          sierdzio
                          Moderators
                          wrote on 27 Jun 2022, 08:15 last edited by
                          #13

                          @komodosp said in Catch exceptions in QT/C++ (QGuiApplication) (override notify() method?):

                          So it doesn't raise exceptions, but does it do anything when the application crashes that could be used to determine what happened?

                          No, by itself containers do not attempt to do anything, that's for performance reasons.

                          But you can get all the info you need by using asan (address sanitizer) or running the app under a debugger. Both ways will show you exactly where and why the crash is happening

                          (Z(:^

                          1 Reply Last reply
                          1

                          11/13

                          26 Jun 2022, 20:58

                          • Login

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