When QSqlDatabase::removeDatabase() is called from a different thread than QSqlDatabase::addDatabase() was called from, I get the following error message:
Error in my_thread_global_end(): 1 threads didn't exit
It is easy to reproduce with the following code sample even without MySql database. But it seems to happen on Ubuntu and NOT on Windows.

Qt Code:
  1. #include <QtCore>
  2. #include <QtSql>
  3.  
  4. class Client: public QObject
  5. {
  6. Q_OBJECT
  7.  
  8. public:
  9. Client();
  10. ~Client();
  11.  
  12. public slots:
  13. void start();
  14.  
  15. signals:
  16. void done();
  17. }; // Client
  18.  
  19. Client::Client()
  20. {
  21. QSqlDatabase::addDatabase("QMYSQL", "my_connection");
  22. }
  23.  
  24. Client::~Client()
  25. {
  26. }
  27.  
  28. void Client::start()
  29. {
  30. // we could do some work here, but for the test simply remove the connection
  31. QSqlDatabase::removeDatabase("my_connection");
  32. emit done();
  33. }
  34.  
  35.  
  36. int main(int argc, char* argv[])
  37. {
  38. QCoreApplication app(argc, argv);
  39.  
  40. Client client;
  41. client.moveToThread(&t);
  42. QObject::connect(&t, SIGNAL(started()), &client, SLOT(start()));
  43. QObject::connect(&client, SIGNAL(done()), &t, SLOT(quit()));
  44. QObject::connect(&t, SIGNAL(finished()), &app, SLOT(quit()));
  45. t.start();
  46.  
  47. return app.exec();
  48. }
  49.  
  50. #include "main.moc"
To copy to clipboard, switch view to plain text mode 

What am I doing wrong?