[Interest] Unique Database connection name

Thiago Macieira thiago.macieira at intel.com
Wed Sep 4 19:06:17 CEST 2013


On quarta-feira, 4 de setembro de 2013 18:23:17, arno wrote:
> void LongRunning::run() {
>    //mydb is set up in a singleton
>    QSqlDatabase db = QSqlDatabase::cloneDatabase("mydb", uniquesting);
>    ... select something from database...
>    End of LongRunning:
>    QSqlDatabase::removeDatabase(uniquestring);
> }
> 
> LongRunning is managed by a QThreadPool. I'm looking for a way to
> generate a unique "uniquestring" for each connection.

Is that the global thread pool, or one of yours? If it's the global pool, it's 
a problem, since you should only run short tasks there.

In any case, the pointer address might be reused, but only after 
removeDatabase. So there's no conflict.

> I tried QUuid, but the documentation is scarce. Seems it's only a class
> for representing a UUID, not for generating one, right?

Hmm... the docs say 
"Most platforms provide a tool for generating new UUIDs, e.g. uuidgen and 
guidgen. You can also use createUuid(). "

But the QUuid::createUuid function is not documented. It exists, it's just not 
documented. Looks like an oversight.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130904/d0351793/attachment.sig>


More information about the Interest mailing list