Solved QRunnable derived class Exception Triggered
-
I have a class derived from QObject and QRunnable:
class RDF : public QObject, QRunnable { Q_OBJECT: private: void run();
The constructor:
RDF::RDF(const char* cpszFullPath, QObject* pParent) : QObject(pParent), QRunnable(), mblnComplete(false), meLastError(RDF_file_ok), mpdsIn(nullptr), mpobjFile(nullptr), mlngBScans(0), mlngLastBscans(0) { if ( cpszFullPath != nullptr ) { const QString cstrFullPath(cpszFullPath); if ( mobjReader.open(cstrFullPath) != true ) { std::cerr << "Failed to open file: " << cstrFullPath.toLatin1().data() << std::endl; return; } QThreadPool::globalInstance()->start(this); } mcnUpdate = QObject::connect(&mtmrUpdate, &QTimer::timeout, [this]() { if ( mblnComplete == true ) { emit complete(mlngBScans); mtmrUpdate.stop(); close(); return; } if ( mlngLastBscans != mlngBScans ) { mlngLastBscans = mlngBScans; emit bscansUpdate(mlngBScans); } } ); mtmrUpdate.start(mscintUpdateInterval); }
In the run implementation:
void RDF::run() { //Do something }
When the leaves the run function an exception is triggered:
-
@SPlatten How does stack trace look like?
Consider this:
"QThreadPool deletes the QRunnable automatically if autoDelete() returns true (the default)" from https://doc.qt.io/qt-5/qrunnable.html -
@SPlatten How does stack trace look like?
Consider this:
"QThreadPool deletes the QRunnable automatically if autoDelete() returns true (the default)" from https://doc.qt.io/qt-5/qrunnable.html -
@jsulm , thank you, I will add setAutoDelete(false) to the constructor.