8000 Enable "modern Qt" compiler definitions by danvratil · Pull Request #66 · qcoro/qcoro · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enable "modern Qt" compiler definitions #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ if (QCORO_ENABLE_ASAN)
endif()
endif()

add_compile_definitions(
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
QT_NO_URL_CAST_FROM_STRING
QT_NO_CAST_FROM_BYTEARRAY
QT_USE_STRINGBUILDER
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
QT_NO_KEYWORDS
QT_NO_FOREACH
)
if (NOT WIN32)
# strict iterators on MSVC only work when Qt itself is also built with them,
# which is not usually the case. Otherwise there are linking issues.
add_compile_definitions(QT_STRICT_ITERATORS)
endif()

include(qcoro/QCoroMacros.cmake)
qcoro_enable_coroutines()

Expand Down
2 changes: 1 addition & 1 deletion tests/qcoronetworkreply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private Q_SLOTS:
private:
QNetworkRequest buildRequest(const QString &path = QString()) {
return QNetworkRequest{
QStringLiteral("http://127.0.0.1:%1/%2").arg(mServer.port()).arg(path)
QUrl{QStringLiteral("http://127.0.0.1:%1/%2").arg(mServer.port()).arg(path)}
};
}

Expand Down
8 changes: 4 additions & 4 deletions tests/qdbuspendingreply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class QCoroDBusPendingCallTest : public QCoro::TestObject<QCoroDBusPendingCallTe
QDBusConnection::sessionBus());
QCORO_VERIFY(iface.isValid());

const QString reply = co_await iface.ping("Hello there!");
const QString reply = co_await iface.ping(QStringLiteral("Hello there!"));

QCORO_COMPARE(reply, QStringLiteral("Hello there!"));
}
Expand All @@ -70,7 +70,7 @@ class QCoroDBusPendingCallTest : public QCoro::TestObject<QCoroDBusPendingCallTe
QVERIFY(iface.isValid());

bool called = false;
qCoro(iface.ping("Hello there!")).waitForFinished().then(
qCoro(iface.ping(QStringLiteral("Hello there!"))).waitForFinished().then(
[&](const QDBusPendingReply<QString> &reply) {
called = true;
el.quit();
Expand Down Expand Up @@ -140,7 +140,7 @@ class QCoroDBusPendingCallTest : public QCoro::TestObject<QCoroDBusPendingCallTe
QDBusConnection::sessionBus());
QCORO_VERIFY(iface.isValid());

QDBusPendingReply<QString, bool> reply = iface.asyncCall("blockAndReturnMultipleArguments", 1);
QDBusPendingReply<QString, bool> reply = iface.asyncCall(QStringLiteral("blockAndReturnMultipleArguments"), 1);
co_await reply;

QCORO_VERIFY(reply.isFinished());
Expand All @@ -153,7 +153,7 @@ class QCoroDBusPendingCallTest : public QCoro::TestObject<QCoroDBusPendingCallTe
QDBusConnection::sessionBus());
QVERIFY(iface.isValid());

QDBusPendingReply<QString, bool> reply = iface.asyncCall("blockAndReturnMultipleArguments", 1);
QDBusPendingReply<QString, bool> reply = iface.asyncCall(QStringLiteral("blockAndReturnMultipleArguments"), 1);
bool called = false;
qCoro(reply).waitForFinished().then([&](const QDBusPendingReply<QString, bool> &reply) {
called = true;
Expand Down
2 changes: 1 addition & 1 deletion tests/testhttpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private Q_SLOTS:
QEventLoop el;

auto reply = std::unique_ptr<QNetworkReply>(
nam.get(QNetworkRequest{url.arg(mServer.port())}));
nam.get(QNetworkRequest{QUrl{url.arg(mServer.port())}}));
connect(reply.get(), &QNetworkReply::finished, &el, &QEventLoop::quit);

QTimer::singleShot(timeout, &el, [&el]() mutable { el.exit(1); });
Expand Down
0