When QFutureWatcher::pause is called, the future is correctly paused, but the paused signal is not emited inmediatly. Moreover, the signal is emitted after the future is resumed.
The problem seems to be in QFutureWatcherBase::event
When a pause event is processed, because the current state is paused, the event is appended to pendingCallOutEvents
When a resume event is processed, the resume event is sent and then all events from pendingCallOutEvents. Thats why resume signal is received and then the pause signal.
The pause event should be sent despite of the current state is paused.
Taking the attached example, this is the output produced:
Note that Paused and Resumed arrived at the same time, and in the code, there is a 5 sec delay between both
It is also noticeable if you put a breakpoint on the following functions:
You will note that pause is called, and onPaused is not, after that, resume is called, and then, onResumed is called and after that onPaused is called.
|For Gerrit Dashboard: QTBUG-12152|
|126633,6||Fix handling of pause and resume events and state in future watchers.||dev||qt/qtbase||Status: ABANDONED||0||0|
|301300,9||Don't queue events in QFutureWatcher when pause is requested||dev||qt/qtbase||Status: MERGED||+2||0|
|301301,14||Add a way of notifying QFutureWatcher when pause is in effect||dev||qt/qtbase||Status: MERGED||+2||0|