[Development] Calling QWindow::requestActivate after QWindow::show and before QTest::qWaitForWindowActive

EXT Mitch Curtis mitch.curtis at qt.io
Tue Aug 12 07:29:33 CEST 2025


First we need to agree on whether or not this is the right thing to do. If we agree that it is, then we should absolutely do that. That’s what I was advocating for in my comments on the change, too.



Confidential
From: David C. Partridge <david.partridge at perdrix.co.uk>
Date: Tuesday, 12 August 2025 at 12:15
To: EXT Mitch Curtis <mitch.curtis at qt.io>
Subject: RE: [Development] Calling QWindow::requestActivate after QWindow::show and before QTest::qWaitForWindowActive
Shouldn't some words about this be added to the user documentation to tell
us not to do that...

D.

-----Original Message-----
From: Development <development-bounces at qt-project.org> On Behalf Of EXT
Mitch Curtis via Development
Sent: 12 August 2025 01:53
To: Qt Development <development at qt-project.org>
Subject: [Development] Calling QWindow::requestActivate after QWindow::show
and before QTest::qWaitForWindowActive

Hi,

There's a discussion on
https://codereview.qt-project.org/c/qt/qtdeclarative/+/666818 about whether
we can standardise (by documenting in some form) that we shouldn't call
requestActivate before qWaitForWindowActive. Essentially, existing code in
tests looks like this:

    window->show();
    window->requestActivate();
    QVERIFY(QTest::qWaitForWindowActive(window.data()));

And would become this:

    window->show();
    QVERIFY(QTest::qWaitForWindowActive(window.data()));

As Axel has explained, this causes race conditions on XCB, and apparently is
redundant on all platforms:

> To begin with, an autotest should be as close as possible to a real world
scenario.
> When the only window around is being shown, it is automatically activated.
The additional window->requestActivate() redundant and not a real world
scenario. This alone justifies its removal.

I'd like to get agreement that this is the right thing to do on all
platforms before proceeding (and then removing it en masse).

Cheers.

Confidential
--
Development mailing list
Development at qt-project.org
https://lists.qt-project.org/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20250812/ba55fccd/attachment.htm>


More information about the Development mailing list