It is very likely that the cause of the unresponsiveness in your app has nothing at all to do with event processing. This sounds more like a classic case of a memory leak (or unrestrained growth of heap data) which is gradually eating all system resources and causing your application to thrash ("thrashing" means that you app has used so much memory that the OS has to keep swapping parts of it out to disk so that other parts can be swapped into execute).
The crash is most likely related to this as well and also has nothing to do with event processing. Likely there is some memory corruption and it just happens to manifest itself with a crash at this point.
Unresponsiveness can also be caused by not allowing the Qt event loop to run frequently enough - such as when the app has a big number-crunching function that takes a long time to run before it returns to the event loop. During the time the method is running, the event loop is blocked. Your app could also simply be generating too many events - if you have a timer that is firing every few ms and causing a cascade of more events as a result of this timeout handler, then it could be that your event queue is simply growing without limit because the app cannot process the events that are there before more get added. Calling processEvents() doesn't help if that just results in even more events being added.
So:
- look for memory leaks or other sources of unrestrained memory growth
- look for use of uninitialized or deleted and invalid memory references
- look for cases where you are calling delete() instead of deleteLater() on a QObject pointer - this can cause crashes if something pending in the event loop still needs that pointer
- look for code that generates too many events - timeouts that are too short, recursive event handlers that create more events, etc.
Note that paintEvent() calls are usually not a source of problems. Qt's event loop is optimized so that if successive paint events are pushed onto the queue, all but the last one will be discarded so painting only happens once.
Bookmarks