Unsolved processEvent() differs between Qt4 and Qt5
-
I'm using
QxtSignalWaiter
to wait synchronously for a signal, with no issues and, as stated in another topic here, it worked fine until Qt5.9/5.10. Then it started to get stuck in theprocessEvent()
call and generate other erratic behaviors.
https://bitbucket.org/libqxt/libqxt/src/696423b68972fc9edae318558b8ce26dc187cc40/src/core/qxtsignalwaiter.cpp#lines-144:145Looking at Qt5 documentation I see 2 additions that are not in the Qt4 manual.
void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents)
[...]
Calling this function processes events only for the calling thread, and returns after all available events have been processed. Available events are events queued before the function call. This means that events that are posted while the function runs will be queued until a later round of event processing.void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int ms)
This function overloads processEvents().
[...]
Note: Unlike the processEvents() overload, this function also processes events that are posted while the function runs.
Note: All events that were queued before the timeout will be processed, however long it takes.This could explain the problem I have, however I never found a warning when reading the Qt4 to Qt5 porting guide. Maybe the change is only in the manual? If not, are there complete list of potential problems to expect when porting to Qt5?
-
@JulienMaille If you want to wait synchronously you should rather use a local event loop: https://doc.qt.io/qt-5/qeventloop.html
-
@JulienMaille said in processEvent() differs between Qt4 and Qt5:
If not, are there complete list of potential problems to expect when porting to Qt5?
QxtSignalWaiter is not a Qt class but Qxt - you should ask there.
-
My question targets processEvent() not Qxt (which stopped being maintained year ago)
-
@JulienMaille said in processEvent() differs between Qt4 and Qt5:
My question targets processEvent()
You are comparing two different overloads...
They are both in both Qt releases, as you can see here:
Qt4:
- 1: https://doc.qt.io/archives/qt-4.8/qcoreapplication.html#processEvents
- 2: https://doc.qt.io/archives/qt-4.8/qcoreapplication.html#processEvents-2
Qt5:
- 1: https://doc.qt.io/qt-5/qcoreapplication.html#processEvents
- 2: https://doc.qt.io/qt-5/qcoreapplication.html#processEvents-1
I guess they just added some more information to the (Qt5) documentation.
-
@JulienMaille said in processEvent() differs between Qt4 and Qt5:
My question targets processEvent() not Qxt
I'm using QxtSignalWaiter to wait synchronously for a signal, with no issues and, as stated in another topic here, it worked fine until Qt5.9/5.10. Then it started to get stuck in the processEvent() call and generate other erratic behaviors.
mhhh...
anyway: fix your code and make it async.