mercredi 22 avril 2015

Internal QTimer isn't killed from the right thread when terminating a QThread

I have a QThread that creates a QGraphicsSimpleTextItem. When I close my application I try to finish the thread and then terminate it.

if( !QThread::wait(1000) )
    QThread::terminate();

Everything is fine until I add a call to QGraphicsSimpleTextItem::setFont() in my thread. If I do so, Qt's internal QFontCache system is called and will start a QTimer (from my thread). Then when I terminate the QThread, killTimer is called (from the main) when Qt cleans up the event loops and I get the error:

QObject::killTimers: timers cannot be stopped from another thread

What should I do to avoid this problem? Shouldn't that be considered as a bug of the font caching mechanism? Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire