Catch exceptions in QT/C++ (QGuiApplication) (override notify() method?)
-
I don't know if this has anything to do with the crash, but your DebugApplication lacks Q_OBJECT macro.
-
Hi and welcome to devnet,
You constructor signature is wrong.
argc must be a reference to an int not an int.
-
Hi and welcome to devnet,
You constructor signature is wrong.
argc must be a reference to an int not an int.
wrote on 23 Jun 2022, 22:22 last edited byThanks! 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.
-
wrote on 24 Jun 2022, 15:12 last edited by
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 ?
-
wrote on 26 Jun 2022, 16:18 last edited by
@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 ?
-
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 ?
wrote on 26 Jun 2022, 20:58 last edited by@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.
-
@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.
-
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.
@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
11/13