summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/client/tst_client.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-02-08 16:53:39 +0100
committerJohan Helsing <johan.helsing@qt.io>2018-02-21 12:38:57 +0000
commitfd9fec4fc7f43fb939e8e5a946c7858390bbd9d3 (patch)
tree8d50133a7e7ccbd5ca7787836396d238151175d8 /tests/auto/client/client/tst_client.cpp
parent3dd9c91b6ebd7f9eccecad90ac57681f6bf6c5d6 (diff)
Fix crash when connecting a new screen
In QWaylandWindow::virtualSiblings, don't include screens that have not been added yet. I.e. QWaylandScreens for which QPlatformIntegration::screenAdded has not yet been called. There are two reasons why this crash wasn't covered by the removePrimaryScreen() test. First of all, the mock output didn't send wl_output.done events when updating the mode/geometry. These wayland events are what causes QWindowSystemInterface::handleScreenGeometryChange() to be called (where virtualSiblings are called). Furthermore, virtualSiblings is only called when the geometry actually changes, so add a new test that changes the screen geometry of the existing screen while a new one is being added (i.e. moves it to the right). Task-number: QTBUG-62044 Change-Id: I623fbf8799d21c6b9293e7120ded301277639cc6 Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Aleix Pol Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests/auto/client/client/tst_client.cpp')
-rw-r--r--tests/auto/client/client/tst_client.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp
index 981b8f129..e244de7f2 100644
--- a/tests/auto/client/client/tst_client.cpp
+++ b/tests/auto/client/client/tst_client.cpp
@@ -164,6 +164,7 @@ public slots:
private slots:
void primaryScreen();
void screens();
+ void addScreenWithGeometryChange();
void windowScreens();
void removePrimaryScreen();
void createDestroyWindow();
@@ -197,6 +198,29 @@ void tst_WaylandClient::screens()
QTRY_COMPARE(QGuiApplication::screens().size(), 1);
}
+//QTBUG-62044
+void tst_WaylandClient::addScreenWithGeometryChange()
+{
+ QTRY_COMPARE(QGuiApplication::screens().size(), 1);
+ const QRect oldGeometry = QGuiApplication::primaryScreen()->geometry();
+ compositor->sendAddOutput();
+
+ // Move the primary screen to the right
+ const QRect newGeometry(QPoint(screenSize.width(), 0), screenSize);
+ Q_ASSERT(oldGeometry != newGeometry);
+ compositor->sendOutputGeometry(compositor->output(0), newGeometry);
+
+ QTRY_COMPARE(QGuiApplication::screens().size(), 2);
+ QTRY_COMPARE(QGuiApplication::primaryScreen()->geometry(), newGeometry);
+
+ compositor->sendRemoveOutput(compositor->output(1));
+ QTRY_COMPARE(QGuiApplication::screens().size(), 1);
+
+ // Move the screen back
+ compositor->sendOutputGeometry(compositor->output(0), oldGeometry);
+ QTRY_COMPARE(QGuiApplication::primaryScreen()->geometry(), oldGeometry);
+}
+
void tst_WaylandClient::windowScreens()
{
QSharedPointer<MockOutput> firstOutput;
@@ -255,6 +279,7 @@ void tst_WaylandClient::removePrimaryScreen()
compositor->sendAddOutput();
QTRY_COMPARE(QGuiApplication::screens().size(), 2);
+ QTRY_COMPARE(QGuiApplication::primaryScreen()->virtualSiblings().size(), 2);
QScreen *secondaryScreen = QGuiApplication::screens().at(1);
QVERIFY(secondaryScreen);