To simulate mouse for test automation purposes mouse events are created with CGEventCreateMouseEvent(nullptr, eventType, p, kCGMouseButtonLeft), where eventType is either kCGEventLeftMouseDown or kCGEventLeftMouseUp. Then these events are posted to the event stream.
Now, since Qt 5.12.1, only QEvent::MouseButtonPress events are caught in the event filter - no QEvent::MouseButtonRelease at all. This started to happen after https://codereview.qt-project.org/#/c/244627/. The fix patch introduces bool initialPress, which in this case is always 'false'.
Reverting the above mentioned patch fixes the problem, but the patch isn't necessarily the root cause. 'initialPress' is 'false', because QMouseEvent::buttons() is 'NoButton' with MouseButtonPress event while according to documentation is should include the button causing the event. And in this case, if it did contain the button causing the event, 'initialPress' would be 'true' and mouse events would flow as expected.
The attached example reproduces the problem. Press the bottom button to start automated mouse click simulation (for the 'Beep' button). See also statusBar message for received events.
Expected result: Cursor moves to center of beepButton, button highlights on and off and there is a beep.
Actual result: Cursor moves to center of beepButton and button highlights on and stays on until the user click on the 'Beep' button.