PDA

View Full Version : It is not safe to use pixmaps outside the GUI thread (but I'm in the GUI thread)



chiiph
7th February 2012, 15:17
Hello,

Si I'm having this issue where Qt complains about with the following:

QPixmap: It is not safe to use pixmaps outside the GUI thread

But I'm doing moveToThread(QApplication::instance()->thread()), and re-checking using the method currentThreadId() whether the move when as expected and it seems to be in the correct thread, and yet it complains.
Also, the object is already in the GUI thread (if I don't use the moveToThread, the Ids are the same).

What could be causing this? Is comparing this->thread()->currentThreadId() == QApplication::instance()->thread()->currentThreadId() not the best way of checking this?

wysota
7th February 2012, 15:26
Hard to say without seeing the code.

chiiph
7th February 2012, 16:19
You can see the code I'm talking about in here:

https://gitweb.torproject.org/chiiph/vidalia.git/blob/featNetworkMap:/src/vidalia/network/NetViewer.cpp#l363

wysota
7th February 2012, 20:15
Where is the pixmap?

chiiph
7th February 2012, 21:39
They are in here: https://gitweb.torproject.org/chiiph/vidalia.git/blob/featNetworkMap:/src/vidalia/network/RouterListItem.cpp with all the QIcons.
This is used by this: https://gitweb.torproject.org/chiiph/vidalia.git/blob/featNetworkMap:/src/vidalia/network/NetViewer.cpp#l391

wysota
7th February 2012, 22:13
Hmmm.... I suggest you cut the minimum of your project and paste it here. I really do not feel like jumping around files of your project.