Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
5.14.2
-
None
Description
Please kindly reference the attached "test-case.txt".
`EventLoop` is a public class which is very convenient to build a message queue (Thanks a lot for the great work!). One of the classic use case is:
- A worker thread is running `EventLoop::exec()` to process events.
- Other threads call `QMetaObject::invokeMethod` to queue jobs (very lightweight jobs can be processed as events).
- A Control thread (usually the main thread) calls "EventLoop::quit" when quitting the Application.
However, if the control thread is moving too fast to call "quit" before the worker thread to call "exec", the "exit" flag will be cleared by "exec", so "exec" will never quit.
Please see the implementation of
```
QEventLoop::exec
```
There is a line
```d->exit.storeRelease(false);```
inside `LoopReference`.
I am not familiar with how the different level of event loops are implemented, and it seems we may set "exit" flag as "false" when constructing an "EventLoop" rather than inside "exec", so if the "exit" flag is set as "true" before entering "exec" it will still work.