[Qt-interest] QSqlQuery + multiple threads = crash
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Wed Jun 22 17:06:03 CEST 2011
> Sent: Wednesday, 22 June 2011 23:06 PM
>
> On Wednesday 22 June 2011 14:55:19 Emmanuel Bourgerie wrote:
> > Would QSqlDatabase copyOfDb(*db) be enough ?
>
> Just use QSqlDatabase::database( "db-name" ) in your worker
> thread to get
> another connection. Then be sure to use each connection only
> in the thread
> they were created in.
>
> Cheers,
>
> Sean
The 4.7.2 QSqlDatabase docs state "If you create multiple database
connections, specify a unique connection name for each one, when you call
addDatabase()." I think you need to have separate names to have separate
connections - at least that's how I've coded my thread pool threads.
Regards,
Tony.
More information about the Qt-interest-old
mailing list