Qt World Summit: Register Today!

ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread.

  • this assert failure is not always met, and it's hard to find where is the bug?
    is there anyway to check all the code, and find the bug(eg.update ui in no-main thread) while compile time?
    when the exe runs, when click "retry" the ASSERT, the debug point stop seems nothing wrong...
    thank you !

  • is there any way or tools which can check all the code is right, especially the UI controlllers are all update in main thread.

  • Qt Champions 2017

    This could be coming in show method of UI as well. You are calling some function of a object in worker thread. This object is owned by the different thread. Internally that function must be calling the sendevent. This could simple show() function your widget as well.

  • sorry, but i am not quite understand what you mean by show()...
    the bug is possibly cause by calling ui's func in no-main thread.
    but the compilation is right, and just ASSERT sometime when running.
    i want to know is there any way to find out the wrongly used code , it's better if i can find all the wrong code while compiling.
    thank you any way

  • Lifetime Qt Champion

    @opengpu2 Well, there are no such tools. And it will compile, its not an compile time issue. You need to check your code - especially your threads.

  • @jsulm thank you, but when the solution is a very big one, there too many codes...and it's not easy to check all the code...
    and when debug runnuing, it sometims will assert, but when click retry, the breakpoint position seems not where the bug is...
    why the breakpoint not locate precisly when click the retry button when Assert?

  • anyone help?

  • Moderators

    Try running thread sanitizer, maybe it will pinpoint the issue.

Log in to reply