Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.14.1
-
None
Description
If a QFileSystemWatcher is created inside a class which is moved to another thread, then the program finishes unexpectedly when exitting.
Example:
class myClass : public QObject { Q_OBJECT QFileSystemWatcher* watcher; public: explicit myClass(QObject *parent = nullptr) : QObject(parent) { watcher = new QFileSystemWatcher(this); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); QThread t; myClass* c = new myClass(); c->moveToThread(&t); QObject::connect(&t, SIGNAL(finished()), c, SLOT(deleteLater())); t.start(QThread::NormalPriority); t.quit(); t.wait(); return app.exec(); }
If watcher is created without "this" as argument in the constructor it works, but then the watcher is not moved along with myClass to the new thread.
Also note that it only fails if app.exec() is called.