Results 1 to 4 of 4

Thread: QMovie::moveToThread() and its QTimer

  1. #1
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QMovie::moveToThread() and its QTimer

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMovie::moveToThread() and its QTimer

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMovie::moveToThread() and its QTimer

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMovie::moveToThread() and its QTimer

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Show Gif from url with QMovie
    By madlymad in forum Newbie
    Replies: 1
    Last Post: 12th November 2010, 15:56
  2. moveToThread() Problem
    By rangerbob in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2009, 18:33
  3. QMovie
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 24th August 2007, 14:23
  4. QObject::moveToThread warning
    By mnemonic_fx in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2007, 22:11
  5. QObject::moveToThread() warnings
    By gri in forum Qt Programming
    Replies: 9
    Last Post: 2nd April 2007, 16:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.