PDA

View Full Version : QMovie::moveToThread() and its QTimer



tiftof
24th February 2011, 10:22
I'm trying to move a QMovie from one thread to another. No problem there. But afterwards I want to start the QMovie in its new thread, this goes wrong. Error message: "timers cannot be started from another thread".

QMovie has a QTimer member variable to trigger for the next frame to load but this timer is just a member and has no parent-child relationship with QMovie it belongs too => when moving the QMovie to another thread, the QTimer doesn't move with it. Is there a reason for this? It seems like a bug to me but I want to double check here.

wysota
24th February 2011, 11:22
What is the reason for moving QMovie to another thread? The timer is a member of QMovie's P-IMPL so it doesn't need to and in fact should be in a parent-child relationship with the QMovie instance. The object will be deleted when the P-IMPL object is deleted which happens in the destructor of QMovie.

tiftof
24th February 2011, 11:50
Deletion of the Timer is indeed covered by the member relationship but this doesn't take care of thread moving which parent-child relationship does take care of.

The reason for moving it to another thread is the structure of the program I'm writing: preparing objects in one thread, move them to another thread and use them there. This reason is the scope of another discussion I think but the fact that moveToThread of QMovie doesn't really work seems like a bug nonetheless.

wysota
24th February 2011, 11:53
But the point is using QMovie from a thread different than the GUI thread doesn't make sense. So why would QMovie be designed in a more complex way only to support something it wouldn't support anyway?