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 <davidedmundson@kde.org>
This commit is contained in:
Ahmad Samir 2023-08-22 20:04:04 +03:00
parent a96b58798e
commit 55d8e22017
2 changed files with 13 additions and 13 deletions

View File

@ -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<const char *>(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;

View File

@ -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