Release ONLY Debug Error: ASSERT "Cannot send events to objects owned by a different thread."



  • Debug Error!

    Program: ...
    Module: 4.5.2
    File: global\qglobal.cpp
    Line: 2030

    ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread 2be7670.
    Receiver '' (of type 'QWidget') was created in thread 2306c00", file kernel\qcoreapplication.cpp, line 305

    Using coin3d / SoQt as follow the error above is catched:

    @
    QWidget *HauptFenster = new QWidget(this);
    setCentralWidget(HauptFenster);
    SoQt::init(HauptFenster);
    Vp = new Robo_Viewer(HauptFenster);

    or (with exactly same error):

    QWidget *HauptFenster = new QWidget(this);
    SoQt::init(HauptFenster);
    Vp = new Robo_Viewer(HauptFenster); // error will not happen, if i comment this line out (but the application cannot use this widget then)
    setCentralWidget(HauptFenster); // neither happens, if this line is commented out

    Robo_Viewer::Robo_Viewer(QWidget * parent)
    :QWidget( parent), SoQtExaminerViewer(parent, NULL, true,
    SoQtFullViewer::BUILD_ALL, SoQtFullViewer::BROWSER, true)
    {
    SoDB::init();
    SoNodeKit::init();
    SoInteraction::init();
    root = new SoSeparator;
    root->ref();
    }
    @
    EDIT (Gerolf) added the @ tags



  • Can you please use '@' tags around your code to make it more readable.



  • http://developer.qt.nokia.com/wiki/ThreadsEventsQObjects .

    I feel that writing that article was the right thing to do :-)



  • Sorry, it was my first posting here, second try:

    msgbox:
    "Debug Error!

    Program: D:\FTP\Robo\release\Robo.exe
    Module: 4.5.2
    File: global\qglobal.cpp
    Line: 2030

    ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread 2be7670.
    Receiver '' (of type 'QWidget') was created in thread 2306c00", file kernel\qcoreapplication.cpp, line 305"

    Using coin3d / SoQt as follow the error above is catched:

    @QWidget *HauptFenster = new QWidget(this);
    setCentralWidget(HauptFenster);
    SoQt::init(HauptFenster);
    Vp = new Robo_Viewer(HauptFenster);
    @

    or (with exactly same error):

    @QWidget *HauptFenster = new QWidget(this);
    SoQt::init(HauptFenster);
    Vp = new Robo_Viewer(HauptFenster); // error will not happen, if i comment this line out (but the application cannot use this widget then)
    setCentralWidget(HauptFenster); // neither happens, if this line is commented out
    @

    Class SoQtViewer:
    @Robo_Viewer::Robo_Viewer(QWidget * parent)
    :QWidget( parent), SoQtExaminerViewer(parent, NULL, true,
    SoQtFullViewer::BUILD_ALL, SoQtFullViewer::BROWSER, true)
    {
    SoDB::init();
    SoNodeKit::init();
    SoInteraction::init();
    root = new SoSeparator;
    root->ref();
    }
    @



  • at peppe:
    thank you very much for your fast answer and the link, but i still do not really understand what the problem is in reality, because the debug build is working fine :-)
    should i not use "this" @new QWidget(this)@ ?
    but why it works in debug?
    how i can use a workaround?
    thank you very much!



  • Hi rezger,
    you can edit your posts for adding such tags. Just click on edit under your avatar.

    The interesting thing is, where is the event send and which event.
    QApplication::sendEvent is a synchronous eventing mechanism. It is not allowed to "send" events cross threads.

    You can set a breakpoint to the location where the assert happens and look at the stack trace to find the sender. Or have a look at the coin3d / SoQt whether you should not use QWidgets for the connection, or if they use threads.



  • at Gerolf:
    i understood nearly everything what you told.
    there is a check in release if the receiver is valid, but this is not checked in debug.
    and the debug works quite fine, even using a not allowed synchronous event across threads, so ...
    but as i am actually debugging third-party-code, it is not that easy, and i am not used in this. i believe it would be helpful to have a class- and thread-diagramm at hand, and i just wish visual c++ would give me such a thing at click. any suggestions to get such a diagram at ease? maybe another tool examinating my project?



  • Sorry, I know currently no tool giving this. If the assert only happens in release mode, debug release mode (yes, it's possible :-) ) and set the breakpoint there and look at the call stack. That's the way, I normally go.



  • gregor, i tried it the last 25 minutes, how to debug release?
    it does not stop at breakpoint ... ;-(



  • You have to add debug info to the build. How to do that depends on the compilers you use.
    With MS compilers, it's adding /Zi for the compiler and /DEBUG for the linker. For gcc you can use -ggdb (see "here":http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html ). But perhaps you also have to add this to Qt (means rebuild Qt) to set breakpoints there. If you compile SoQt by your own, I would build that one with debug info and yours and look for sendEvent in SoQt and set breakpoints.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.