Don't create platform window for QWindows when calling setVisible(false)
We can defer the creation until the window is shown. Change-Id: I3d5b45ae59ee0925996cf12cd46dd574c8c6ef95 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
9bf8cc1f18
commit
09e7a994d1
@ -532,7 +532,9 @@ void QWindow::setVisible(bool visible)
|
|||||||
// can defer creation until the parent is created or we're re-parented.
|
// can defer creation until the parent is created or we're re-parented.
|
||||||
if (parent() && !parent()->handle())
|
if (parent() && !parent()->handle())
|
||||||
return;
|
return;
|
||||||
else
|
|
||||||
|
// We only need to create the window if it's being shown
|
||||||
|
if (visible)
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,7 +576,8 @@ void QWindow::setVisible(bool visible)
|
|||||||
d->applyCursor();
|
d->applyCursor();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
d->platformWindow->setVisible(visible);
|
if (d->platformWindow)
|
||||||
|
d->platformWindow->setVisible(visible);
|
||||||
|
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
QHideEvent hideEvent;
|
QHideEvent hideEvent;
|
||||||
|
@ -56,6 +56,7 @@ private slots:
|
|||||||
void create();
|
void create();
|
||||||
void setParent();
|
void setParent();
|
||||||
void setVisible();
|
void setVisible();
|
||||||
|
void setVisibleFalseDoesNotCreateWindow();
|
||||||
void eventOrderOnShow();
|
void eventOrderOnShow();
|
||||||
void resizeEventAfterResize();
|
void resizeEventAfterResize();
|
||||||
void exposeEventOnShrink_QTBUG54040();
|
void exposeEventOnShrink_QTBUG54040();
|
||||||
@ -234,6 +235,16 @@ void tst_QWindow::setVisible()
|
|||||||
QVERIFY(QTest::qWaitForWindowExposed(&i));
|
QVERIFY(QTest::qWaitForWindowExposed(&i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QWindow::setVisibleFalseDoesNotCreateWindow()
|
||||||
|
{
|
||||||
|
QWindow w;
|
||||||
|
QVERIFY(!w.handle());
|
||||||
|
w.setVisible(false);
|
||||||
|
QVERIFY2(!w.handle(), "Hiding a non-created window doesn't create it");
|
||||||
|
w.setVisible(true);
|
||||||
|
QVERIFY2(w.handle(), "Showing a non-created window creates it");
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QWindow::mapGlobal()
|
void tst_QWindow::mapGlobal()
|
||||||
{
|
{
|
||||||
QWindow a;
|
QWindow a;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user