Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved QMediaPlayer in multithreading env (5.10 CE)

    General and Desktop
    1
    1
    245
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Stanislav Silnicki
      Stanislav Silnicki last edited by

      Hi All!

      I'm implementing a media (video) player for multi-screen environment. Simultaneous start, etc...

      So, I instantiate several threads (Player class: public QThread). In each thread in its run() I create a new QMediaPlayer with nullptr as it's parent QObject. So I assume, that the object exists only in a new thread as soon as it is instantiated within a new thread inside run() func. and has no connection with othre threads ( I know, that QThread obejct itself resides in parent's thread, etc.).
      When the first thread (Player) for the first screen is created, nothing interesting is happening. But when exactly same second thread hits CPU, this strange warning appears in error stream:

      QObject: Cannot create children for a parent that is in a different thread.
      (Parent is QObject(0x7fd9ba6d9f20), parent's thread is Player(0x55bc41591c20), current thread is Player(0x55bc41608b20)
      

      Indeed, its only a warning, that doesn't break the functionality, so both players work fine and both screens show proper content.

      But what is the nature of this warning? Looks like both instances of QMediaPlayer somehow interferes?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post