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. sendPostedEvents() or processEvents() causes SIGSEGV
QtWS25 Last Chance

sendPostedEvents() or processEvents() causes SIGSEGV

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 959 Views
  • 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.
  • Q Offline
    Q Offline
    qtstarter101
    wrote on last edited by
    #1

    So I have had this issue with what appeared to be too many events occuring in my application, so the event loop was getting blocked and basically the application became completely unresponsive.
    The way I was trying to fix this issue was to call sendPostedEvents() or processEvents() at the very beginning of a function which is essentially the starting point of all GUI updates that are happening too frequently causing this event loop blocking / unresponsiveness (i.e this function is what is being called so many times within a short period of time). So when I have the sendPostedEvents() or processEvents() function calls, it seems to run a lot better( faster updates and makes the GUI responsive), but after a little while, I suddenly get a segmentation fault, and I'm really not understanding what the cause could be just by reading the stack trace. Any ideas as to what could be going on?

    #4 0xf70684e2 in OA::QtEventHandler:ispatchEvent::invoke (this=0xec9c8050)
    at QtEventHandler.cpp:278
    #5 0xf706857d in OA::QtEventHandler::customEvent (this=0x94e1f48, event=0xec9c8050)
    at QtEventHandler.cpp:254
    #6 0xf579be1a in QObject::event(QEvent*) ()
    from /view/qt-everywhere-opensource-src-4.8.7/lib/libQtCore.so.4
    #7 0xf5a436e4 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    from /view/qt-everywhere-opensource-src-4.8.7/lib/libQtGui.so.4
    #8 0xf5a4a0ad in QApplication::notify(QObject*, QEvent*) ()
    from /view/qt-everywhere-opensource-src-4.8.7/lib/libQtGui.so.4
    #9 0xf70654c0 in OA::QtApplication::notify (this=0xffb17c58, receiver=0x94e1f48, event=0xec9c8050)
    at QtApplication.cpp:55
    #10 0xf5783daa in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
    from /view/qt-everywhere-opensource-src-4.8.7/lib/libQtCore.so.4
    #11 0xf578713d in QCoreApplicationPrivate::sendPostedEvents(QObject* , int, QThreadData*) ()
    from /view/qt-everywhere-opensource-src-4.8.7/lib/libQtCore.so.4
    #12 0xf578762c in QCoreApplication::sendPostedEvents(QObject*, int) ()
    from /view/qt-everywhere-opensource-src-4.8.7/lib/libQtCore.so.4
    #13 0xf678514e in sendPostedEvents ()

    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What exactly are you doing in your application ?

      Why use Qt 4.8.7 ? It has reached end of life a long time ago ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qtstarter101
        wrote on last edited by qtstarter101
        #3

        I am drawing a bunch of QGraphicsItem s and making updates to them and also updating a widget table with data. This is all happening very often and the starting point is some function called Update( ) which is where I decided to put my sendPostedEvents / processEvents call. I have no choice but to use the version of Qt I am using because that's what I have to work with at my company and there's no way I can just upgrade it.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Where are your data coming from ?
          What kind of events are you posting ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qtstarter101
            wrote on last edited by qtstarter101
            #5

            Data is coming from another process through some kind of interprocess communication framework. I'm not posting any events in particular. I'm just trying to get my GUI to be responsive because clearly the event loop is being hogged by the numerous calls to Update() so by sending posted events / processing events every time this function is called, I can get things like button presses, navigation etc. to work in my application. So I guess what I mean is that I'm posting all events that are queued.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              How fast are they coming ?
              What processing do you apply to them ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                qtstarter101
                wrote on last edited by
                #7

                So essentially there are up to 1000 calls to this Update( ) function every 2 secs. The processing is basically sending information to a table widget and updating the fields, and also sending the information somewhere to create graphics items and add them to a graphics scene ( several items for each of the 1000 ), and the items are added to the scene and become visible. Basically I see that likely too many operations are happening within a short period of time so in my mind the best way to get things to be more responsive is to call processEvents or sendPostedEvents but I guess I'm somehow sending events that will result in some invalid memory access somewhere causing a crash, I just don't see how this could have happened and what else I could try to make my GUI responsive.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  So it looks like you are trying to push everything possible all the time.

                  You should rather optimise your data processing so your GUI updates "make sense". There's no use trying to do updates at 1000Hz while the computer can at best be at about 100

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  4

                  • Login

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