Unsolved Catch exceptions in QT/C++ (QGuiApplication) (override notify() method?)
-
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 signalBut 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)
-
Qt does not raise exceptions, so you cannot catch them.
-
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.
-
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.
-
Do you have a lot of containers in your application ?
-
@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
-
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 ?
-
@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.
-
@komodosp
Should this code be generating a core dump? Can't even find that....QStringList stringlist {"hello"}; qDebug() << "String 2 is " << stringlist[2];
-
@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