Single sql connection should not be used from a different thread that it is created in (and some drivers may have additional limitations). Correct me if I am wrong, but I believe it should be working in a way that I implemented it in attached example.
This does not happen every time, but running this example 10 times usually fails somewhere.
Sometimes error messages are printed, such as:
Sometimes there is an assert:
It may also get stuck in qt_call_post_routines() (qcoreapplication.cpp) calling (list->takeFirst())() which makes calls to cleanDriverDict continuously.
Sometimes it may even crash (see attachment). Sometimes it crashes inside sqlite library too.