translate() calls in QtSql

Thiago Macieira thiago at kde.org
Mon May 18 06:19:08 BST 2009


Nick Shaforostoff wrote:
>My user was hit by this crash:
> https://bugs.kde.org/show_bug.cgi?id=193063
>
>Apparently, it is caused by calling QCoreApplication::translate from
> QSQLiteResultPrivate::fetchNext (running in background thread in my
> app):
> http://cep.xor.aps.anl.gov/software/qt4-x11-4.2.2-browser/d8/d09/qsql__
>sqlite_8cpp-source.html
>
>Note that the error text is set immediately, and not when it is
> requested by a programmer. (i.e. by calling QSqlQuery::lastError ()).
>(so that he at least could protect such calls with mutexes)
>
>It is common to run queries in background thread, so any program that
> does this is prone to crashes.
>
>So one solution that came to my mind is switching to lazy setting of
> error texts: the driver sets error code, and when the error text is
> requested, the text is looked up in special table.
>
>What do you think?
>Should I file the bug report to Qt?

No.

I don't understand the error (and bugzilla won't load).

What's wrong? What's the error?

The QCoreApplication::translate() function is explicitly marked as being 
reentrant (http://doc.trolltech.com/4.5/qcoreapplication.html#translate, 
http://doc.trolltech.com/4.5/threads.html#reentrant), which means it's 
safe to call translate() without a mutex.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090518/f69e632e/attachment.sig>


More information about the kde-core-devel mailing list