From e637d432111f14639ed3388e11f5dc2188e9e676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Wed, 7 Nov 2018 17:44:38 +0100 Subject: [PATCH] Remove potential endless loop from XClipboardSyncTest Summary: We need to wait till the helper process created the datadevice. For this we used a while loop. On build.kde.org the test gets stuck in this loop and times out after 10 minutes. This change introduces a dedicated signal and we just wait for it. So if something fails we wait only 5 sec instead of endless. This should help investigate why the test doesn't work on build.kde.org. Test Plan: Test works locally Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D16741 --- autotests/integration/xclipboardsync_test.cpp | 6 ++++-- wayland_server.cpp | 1 + wayland_server.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/autotests/integration/xclipboardsync_test.cpp b/autotests/integration/xclipboardsync_test.cpp index ee9a5e6752..143f644f8d 100644 --- a/autotests/integration/xclipboardsync_test.cpp +++ b/autotests/integration/xclipboardsync_test.cpp @@ -56,6 +56,8 @@ void XClipboardSyncTest::initTestCase() QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); + QSignalSpy clipboardSyncDevicedCreated{waylandServer(), &WaylandServer::xclipboardSyncDataDeviceCreated}; + QVERIFY(clipboardSyncDevicedCreated.isValid()); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); kwinApp()->start(); @@ -65,8 +67,8 @@ void XClipboardSyncTest::initTestCase() QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); waylandServer()->initWorkspace(); // wait till the xclipboard sync data device is created - while (waylandServer()->xclipboardSyncDataDevice().isNull()) { - QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); + if (clipboardSyncDevicedCreated.empty()) { + QVERIFY(clipboardSyncDevicedCreated.wait()); } QVERIFY(!waylandServer()->xclipboardSyncDataDevice().isNull()); } diff --git a/wayland_server.cpp b/wayland_server.cpp index 90db349f74..6c590f6a06 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -246,6 +246,7 @@ bool WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags) [this] (DataDeviceInterface *ddi) { if (ddi->client() == m_xclipbaordSync.client && m_xclipbaordSync.client != nullptr) { m_xclipbaordSync.ddi = QPointer(ddi); + emit xclipboardSyncDataDeviceCreated(); connect(m_xclipbaordSync.ddi.data(), &DataDeviceInterface::selectionChanged, this, [this] { // testing whether the active client inherits Client diff --git a/wayland_server.h b/wayland_server.h index 60dbcc0ade..bc0a589983 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -210,6 +210,7 @@ Q_SIGNALS: void terminatingInternalClientConnection(); void initialized(); void foreignTransientChanged(KWayland::Server::SurfaceInterface *child); + void xclipboardSyncDataDeviceCreated(); private: void setupX11ClipboardSync();