QCoro 0.13.0 Release Announcement
This release brings improvements to generators, better build system integration and several bugfixes.
As always, big thanks to everyone who reported issues and contributed to QCoro. Your help is much appreciated!
Directly Awaiting Qt Types in AsyncGenerator Coroutines
The biggest improvement in this release is that QCoro::AsyncGenerator coroutines now support
directly co_awaiting Qt types without the qCoro() wrapper, just like QCoro::Task coroutines
already do (#292).
Previously, if you wanted to await a QNetworkReply inside an AsyncGenerator, you had to
wrap it with qCoro():
QCoro::AsyncGenerator<QByteArray> fetchPages(QNetworkAccessManager &nam, QStringList urls) {
for (const auto &url : urls) {
auto *reply = co_await qCoro(nam.get(QNetworkRequest{QUrl{url}}));
co_yield reply->readAll();
}
}
Starting with QCoro 0.13.0, you can co_await directly, just like in QCoro::Task:
QCoro::AsyncGenerator<QByteArray> fetchPages(QNetworkAccessManager &nam, QStringList urls) {
for (const auto &url : urls) {
auto *reply = co_await nam.get(QNetworkRequest{QUrl{url}});
co_yield reply->readAll();
}
}
Other Features and Changes
- Generator’s
.end()method is nowconst(andconstexpr), so it can be called on const generator objects (#294). GeneratorIteratorcan now be constructed in an invalid state, allowing lazy initialization of iterators (#318).qcoro.hnow only includes QtNetwork and QtDBus headers when those features are actually enabled, resulting in cleaner builds when optional modules are disabled (#280).
Bugfixes
- Fixed memory leak in QFuture coro wrapper when a task is destroyed while awaiting on a QFuture (#312, Daniel Vrátil)
- Fixed include paths when using QCoro with CMake’s FetchContent (#282, Daniel Vrátil; #310, Nicolas Fella)
- Fixed QCoroNetworkReply test on Qt 6.10 (#305, Daniel Vrátil)
Full changelog
Support
If you enjoy using QCoro, consider supporting its development on GitHub Sponsors or buy me a coffee on Ko-fi (after all, more coffee means more code, right?).