Priority: P3: Somewhat important
Affects Version/s: 4.6.2, 5.5.0
Fix Version/s: 6.0.0
Component/s: Core: QtConcurrent
Environment:In Windows but seems to be a common problem
Sprint:Qt6_Foundation_ Sprint 9, Qt6_Foundation_ Sprint 10
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.