Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-20816

Assertion failure in QCoreApplication::sendEvent if a child object of a parent object moved to different thread is destroyed in the parent destructor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.7.4
    • Core: Object Model
    • None
    • Harmattan Scratchbox/X86

    Description

      • Define a QObject-derived parent class with a child object of QObject-derived class
      • When the child object is created, set its parent to be the parent object
      • In the parent class destructor explicitly destroy the child object (or let the compiler do it if the object is embedded into the parent)
      • Create an instance of the parent class
      • Create a new thread
      • Move the parent class instance to the thread with QObject::moveToThread
      • Start the thread and wait for it to finish
      • Destroy the parent class instance

      Expected:

      • The parent and child objects will be destroyed cleanly

      Actual:

      • The child object destruction fails with assertion
        ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread xxxxxxx. Receiver '' (of type 'ttt') was created in thread yyyyyyy", file kernel/qcoreapplication.cpp, line 405

      Notes:

      • If the child is held by a pointer variable, which is not deleted in the parent class destructor there is no assertion failure
      • The problem does not exist in Qt 4.7.2 (-0ubuntu6.2), which makes this seem like a regression or at least a change in behavior.
      • See also the attached test program.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            srosenda Sami Rosendahl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes