This can only happen if workThread wasn't created and you're trying to
get a Database from a wrong thread.
if (QThread::currentThread() == thread())
return db;
// QThread is in the thread that created it.
- if (QThread::currentThread() == workThread->database()->thread())
+ if (workThread && QThread::currentThread() == workThread->database()->thread())
return workThread->database();
+
+ qWarning("Tried to get a database from a different thread. Qt database "
+ "plugins are not thread-safe. This extends to the LML Database. "
+ "You can only use a Database from the thread in which MyList was "
+ "created.");
+
return 0;
}