sendPostedEvents() or processEvents() causes SIGSEGV
-
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.
-
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 ?
-
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.
-
Where are your data coming from ?
What kind of events are you posting ? -
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.
-
How fast are they coming ?
What processing do you apply to them ? -
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.
-
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