Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Release ONLY Debug Error: ASSERT "Cannot send events to objects owned by a different thread."
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 14.1k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rezger
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vcsala
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

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

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

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rezger
          wrote on last edited by
          #4

          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();
          }
          @

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rezger
            wrote on last edited by
            #5

            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!

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              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.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rezger
                wrote on last edited by
                #7

                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?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  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.

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    rezger
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #10

                      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.

                      Nokia Certified Qt Specialist.
                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved