From 55d8e220171cd04b02d8a2cd0af045bffdcfcc38 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 22 Aug 2023 20:04:04 +0300 Subject: [PATCH] Mark the whole repo with QT_NO_CONTEXTLESS_CONNECT By adding it to the default build flags via .cmake.conf. tst_primaryselectionv1 and tst_datadevicev1: the connection type needs to be explicitly set to DirectConnection, otherwise the test fails. The sender and receiver are the same object, so typically would be in the same thread. The docs say: "If the receiver lives in the thread that emits the signal, Qt::DirectConnection is used." I suspect because the code is running inside CoreCompositor::exec() the signaling thread is different from the thread the objects live in, so leaving the type as AutoConnection when sender/receiver are the same object doesn't lead to the type becoming DirectConnection. Task-number: QTBUG-116296 Change-Id: Iad49889134a78fa723973ba6efbc237038f35b82 Reviewed-by: David Edmundson --- .../wayland/datadevicev1/tst_datadevicev1.cpp | 16 ++++++++-------- .../tst_primaryselectionv1.cpp | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/auto/wayland/datadevicev1/tst_datadevicev1.cpp b/tests/auto/wayland/datadevicev1/tst_datadevicev1.cpp index 3464d0d7861..ef966b9c9d3 100644 --- a/tests/auto/wayland/datadevicev1/tst_datadevicev1.cpp +++ b/tests/auto/wayland/datadevicev1/tst_datadevicev1.cpp @@ -65,13 +65,13 @@ void tst_datadevicev1::pasteAscii() exec([&] { auto *client = xdgSurface()->resource()->client(); auto *offer = dataDevice()->sendDataOffer(client, {"text/plain"}); - connect(offer, &DataOffer::receive, [](QString mimeType, int fd) { + connect(offer, &DataOffer::receive, offer, [](QString mimeType, int fd) { QFile file; file.open(fd, QIODevice::WriteOnly, QFile::FileHandleFlag::AutoCloseHandle); QCOMPARE(mimeType, "text/plain"); file.write(QByteArray("normal ascii")); file.close(); - }); + }, Qt::DirectConnection); dataDevice()->sendSelection(offer); auto *surface = xdgSurface()->m_surface; @@ -103,13 +103,13 @@ void tst_datadevicev1::pasteUtf8() exec([&] { auto *client = xdgSurface()->resource()->client(); auto *offer = dataDevice()->sendDataOffer(client, {"text/plain", "text/plain;charset=utf-8"}); - connect(offer, &DataOffer::receive, [](QString mimeType, int fd) { + connect(offer, &DataOffer::receive, offer, [](QString mimeType, int fd) { QFile file; file.open(fd, QIODevice::WriteOnly, QFile::FileHandleFlag::AutoCloseHandle); QCOMPARE(mimeType, "text/plain;charset=utf-8"); file.write(QByteArray("face with tears of joy: 😂")); file.close(); - }); + }, Qt::DirectConnection); dataDevice()->sendSelection(offer); auto *surface = xdgSurface()->m_surface; @@ -141,7 +141,7 @@ void tst_datadevicev1::pasteMozUrl() exec([&] { auto *client = xdgSurface()->resource()->client(); auto *offer = dataDevice()->sendDataOffer(client, {"text/x-moz-url"}); - connect(offer, &DataOffer::receive, [](QString mimeType, int fd) { + connect(offer, &DataOffer::receive, offer, [](QString mimeType, int fd) { QFile file; file.open(fd, QIODevice::WriteOnly, QFile::FileHandleFlag::AutoCloseHandle); QCOMPARE(mimeType, "text/x-moz-url"); @@ -149,7 +149,7 @@ void tst_datadevicev1::pasteMozUrl() // Need UTF-16. file.write(reinterpret_cast(content.data()), content.size() * 2); file.close(); - }); + }, Qt::DirectConnection); dataDevice()->sendSelection(offer); auto *surface = xdgSurface()->m_surface; @@ -184,14 +184,14 @@ void tst_datadevicev1::pasteSingleUtf8MozUrl() exec([&] { auto *client = xdgSurface()->resource()->client(); auto *offer = dataDevice()->sendDataOffer(client, {"text/x-moz-url"}); - connect(offer, &DataOffer::receive, [](QString mimeType, int fd) { + connect(offer, &DataOffer::receive, offer, [](QString mimeType, int fd) { QFile file; file.open(fd, QIODevice::WriteOnly, QFile::FileHandleFlag::AutoCloseHandle); QCOMPARE(mimeType, "text/x-moz-url"); const QString content("https://www.qt.io/"); file.write(content.toUtf8()); file.close(); - }); + }, Qt::DirectConnection); dataDevice()->sendSelection(offer); auto *surface = xdgSurface()->m_surface; diff --git a/tests/auto/wayland/primaryselectionv1/tst_primaryselectionv1.cpp b/tests/auto/wayland/primaryselectionv1/tst_primaryselectionv1.cpp index d9e4ff295b6..b5539f1f09e 100644 --- a/tests/auto/wayland/primaryselectionv1/tst_primaryselectionv1.cpp +++ b/tests/auto/wayland/primaryselectionv1/tst_primaryselectionv1.cpp @@ -290,13 +290,13 @@ void tst_primaryselectionv1::pasteAscii() auto *device = primarySelectionDevice(); auto *offer = device->sendDataOffer({"text/plain"}); - connect(offer, &PrimarySelectionOfferV1::receive, [](QString mimeType, int fd) { + connect(offer, &PrimarySelectionOfferV1::receive, offer, [](QString mimeType, int fd) { QFile file; file.open(fd, QIODevice::WriteOnly, QFile::FileHandleFlag::AutoCloseHandle); QCOMPARE(mimeType, "text/plain"); file.write(QByteArray("normal ascii")); file.close(); - }); + }, Qt::DirectConnection); device->sendSelection(offer); pointer()->sendEnter(surface, {32, 32}); @@ -336,13 +336,13 @@ void tst_primaryselectionv1::pasteUtf8() auto *device = primarySelectionDevice(); auto *offer = device->sendDataOffer({"text/plain", "text/plain;charset=utf-8"}); - connect(offer, &PrimarySelectionOfferV1::receive, [](QString mimeType, int fd) { + connect(offer, &PrimarySelectionOfferV1::receive, offer, [](QString mimeType, int fd) { QFile file; file.open(fd, QIODevice::WriteOnly, QFile::FileHandleFlag::AutoCloseHandle); QCOMPARE(mimeType, "text/plain;charset=utf-8"); file.write(QByteArray("face with tears of joy: 😂")); file.close(); - }); + }, Qt::DirectConnection); device->sendSelection(offer); pointer()->sendEnter(surface, {32, 32}); @@ -464,7 +464,7 @@ void tst_primaryselectionv1::copy() pastedBuf.append(buf, n); } }); - }); + }, Qt::DirectConnection); }); QCOMPOSITOR_TRY_VERIFY(pastedBuf.size()); // this assumes we got everything in one read