Details
-
Bug
-
Resolution: Cannot Reproduce
-
Not Evaluated
-
None
-
4.8.6
-
None
-
Ubuntu
Description
In a multithreaded application when removing a MySql connection the error occurs:
mushroom@ubuntu:~/projects/mysqltest/mysqlthread/debug$ ./mysqlthread
Error in my_thread_global_end(): 51 threads didn't exit
Error in my_thread_global_end(): 65 threads didn't exit
Here is the code to demonstrate the issue:
mysqlthread.cpp
#include <QtCore> #include <QtSql> class Client: public QRunnable { public: virtual void run(); }; void Client::run() { { QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", QString::number((unsigned long long)QThread::currentThreadId())); db.setHostName("localhost"); db.setDatabaseName("test"); db.setUserName("me"); db.setPassword("mypass"); db.open(); db.close(); } QSqlDatabase::removeDatabase(QString::number((unsigned long long)QThread::currentThreadId())); } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QThreadPool pool; pool.setMaxThreadCount(100); for (int i = 0; i < 100; ++i) { Client *client = new Client; bool started = pool.tryStart(client); Q_ASSERT(started); } pool.waitForDone(); //return a.exec(); return 0; }