<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"><link rel="self" href="https://dvratil.cz//feed.xml" type="application/atom+xml"/><link rel="alternate" href="https://dvratil.cz/" tyle="text/html"/><id>https://dvratil.cz/</id><updated>2026-02-13T00:00:00+0000</updated><title>Daniel Vrátil's blog Daniel Vrátil's blog category feed</title><subtitle>Because opensource matters.</subtitle><author><name>Daniel Vrátil</name><email>me@dvratil.cz</email><uri>https://dvratil.cz/</uri></author><entry><title>QCoro</title><link rel="alternate" href="https://dvratil.cz/project/qcoro/"/><id>https://dvratil.cz/project/qcoro/</id><published>0001-01-01T00:00:00+0000</published><updated>0001-01-01T00:00:00+0000</updated><summary>&lt;p&gt;QCoro is a C++ library that makes it possible to use C++20 coroutines with Qt. It provides
the necessary tools to create coroutines as well as coroutine-friendly wrappers for native
Qt types.&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/project/qcoro/">&lt;p&gt;QCoro is a C++ library that makes it possible to use C++20 coroutines with Qt. It provides
the necessary tools to create coroutines as well as coroutine-friendly wrappers for native
Qt types.&lt;/p&gt;</content></entry><entry><title>KDE</title><link rel="alternate" href="https://dvratil.cz/project/kde/"/><id>https://dvratil.cz/project/kde/</id><published>0001-01-01T00:00:00+0000</published><updated>0001-01-01T00:00:00+0000</updated><summary>&lt;p&gt;I have been contributing to KDE for over a decade. I was involved in KDE Telepathy, KScreen and
most prominently in KDE PIM. I am Akonadi maintainer and author or Google integration.&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/project/kde/">&lt;p&gt;I have been contributing to KDE for over a decade. I was involved in KDE Telepathy, KScreen and
most prominently in KDE PIM. I am Akonadi maintainer and author or Google integration.&lt;/p&gt;</content></entry><entry><title>cmake-package</title><link rel="alternate" href="https://dvratil.cz/project/rust-cmake-package/"/><id>https://dvratil.cz/project/rust-cmake-package/</id><published>0001-01-01T00:00:00+0000</published><updated>0001-01-01T00:00:00+0000</updated><summary>&lt;p&gt;A Rust crate for Cargo build scripts that provides a simple way to find and use CMake package
installed on the system.&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/project/rust-cmake-package/">&lt;p&gt;A Rust crate for Cargo build scripts that provides a simple way to find and use CMake package
installed on the system.&lt;/p&gt;</content></entry><entry><title>QCoro 0.13.0 Release Announcement</title><link rel="alternate" href="https://dvratil.cz/2026/02/qcoro-0.13.0-release-announcement/"/><id>https://dvratil.cz/2026/02/qcoro-0.13.0-release-announcement/</id><published>2026-02-13T00:00:00+0000</published><updated>2026-02-13T00:00:00+0000</updated><category term="QCoro"/><summary>&lt;!--
SPDX-FileCopyrightText: 2026 Daniel Vrátil &lt;dvratil@kde.org&gt;
SPDX-License-Identifier: GFDL-1.3-or-later
--&gt;
&lt;p&gt;This release brings improvements to generators, better build system integration and
several bugfixes.&lt;/p&gt;
&lt;p&gt;As always, big thanks to everyone who reported issues and contributed to QCoro.
Your help is much appreciated!&lt;/p&gt;
&lt;h2 id="directly-awaiting-qt-types-in-asyncgenerator-coroutines"&gt;Directly Awaiting Qt Types in AsyncGenerator Coroutines&lt;/h2&gt;
&lt;p&gt;The biggest improvement in this release is that &lt;code&gt;QCoro::AsyncGenerator&lt;/code&gt; coroutines now support
directly &lt;code&gt;co_await&lt;/code&gt;ing Qt types without the &lt;code&gt;qCoro()&lt;/code&gt; wrapper, just like &lt;code&gt;QCoro::Task&lt;/code&gt; coroutines
already do (&lt;a href="https://github.com/qcoro/qcoro/issues/292"&gt;#292&lt;/a&gt;).&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/2026/02/qcoro-0.13.0-release-announcement/">&lt;!--
SPDX-FileCopyrightText: 2026 Daniel Vrátil &lt;dvratil@kde.org&gt;
SPDX-License-Identifier: GFDL-1.3-or-later
--&gt;
&lt;p&gt;This release brings improvements to generators, better build system integration and
several bugfixes.&lt;/p&gt;
&lt;p&gt;As always, big thanks to everyone who reported issues and contributed to QCoro.
Your help is much appreciated!&lt;/p&gt;
&lt;h2 id="directly-awaiting-qt-types-in-asyncgenerator-coroutines"&gt;Directly Awaiting Qt Types in AsyncGenerator Coroutines&lt;/h2&gt;
&lt;p&gt;The biggest improvement in this release is that &lt;code&gt;QCoro::AsyncGenerator&lt;/code&gt; coroutines now support
directly &lt;code&gt;co_await&lt;/code&gt;ing Qt types without the &lt;code&gt;qCoro()&lt;/code&gt; wrapper, just like &lt;code&gt;QCoro::Task&lt;/code&gt; coroutines
already do (&lt;a href="https://github.com/qcoro/qcoro/issues/292"&gt;#292&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Previously, if you wanted to await a &lt;code&gt;QNetworkReply&lt;/code&gt; inside an &lt;code&gt;AsyncGenerator&lt;/code&gt;, you had to
wrap it with &lt;code&gt;qCoro()&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;AsyncGenerator&lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt;QByteArray&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; fetchPages(QNetworkAccessManager &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;nam, QStringList urls) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;auto&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;url : urls) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;auto&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;reply &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; qCoro(nam.get(QNetworkRequest{QUrl{url}}));
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;co_yield&lt;/span&gt; reply&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;readAll();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Starting with QCoro 0.13.0, you can &lt;code&gt;co_await&lt;/code&gt; directly, just like in &lt;code&gt;QCoro::Task&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;AsyncGenerator&lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt;QByteArray&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; fetchPages(QNetworkAccessManager &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;nam, QStringList urls) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;auto&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;url : urls) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;auto&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;reply &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; nam.get(QNetworkRequest{QUrl{url}});
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;co_yield&lt;/span&gt; reply&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;readAll();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="other-features-and-changes"&gt;Other Features and Changes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Generator&amp;rsquo;s &lt;code&gt;.end()&lt;/code&gt; method is now &lt;code&gt;const&lt;/code&gt; (and &lt;code&gt;constexpr&lt;/code&gt;), so it can be called on const generator objects (&lt;a href="https://github.com/qcoro/qcoro/issues/294"&gt;#294&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GeneratorIterator&lt;/code&gt; can now be constructed in an invalid state, allowing lazy initialization of iterators (&lt;a href="https://github.com/qcoro/qcoro/issues/318"&gt;#318&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;qcoro.h&lt;/code&gt; now only includes QtNetwork and QtDBus headers when those features are actually enabled, resulting in cleaner builds when optional modules are disabled (&lt;a href="https://github.com/qcoro/qcoro/issues/280"&gt;#280&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="bugfixes"&gt;Bugfixes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Fixed memory leak in QFuture coro wrapper when a task is destroyed while awaiting on a QFuture (&lt;a href="https://github.com/qcoro/qcoro/issues/312"&gt;#312&lt;/a&gt;, Daniel Vrátil)&lt;/li&gt;
&lt;li&gt;Fixed include paths when using QCoro with CMake&amp;rsquo;s FetchContent (&lt;a href="https://github.com/qcoro/qcoro/issues/282"&gt;#282&lt;/a&gt;, Daniel Vrátil; &lt;a href="https://github.com/qcoro/qcoro/pull/310"&gt;#310&lt;/a&gt;, Nicolas Fella)&lt;/li&gt;
&lt;li&gt;Fixed QCoroNetworkReply test on Qt 6.10 (&lt;a href="https://github.com/qcoro/qcoro/pull/305"&gt;#305&lt;/a&gt;, Daniel Vrátil)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="full-changelog"&gt;Full changelog&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/danvratil/qcoro/releases/tag/v0.13.0"&gt;See changelog on Github&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="support"&gt;Support&lt;/h2&gt;
&lt;p&gt;If you enjoy using QCoro, consider supporting its development on &lt;a href="https://github.com/sponsors/danvratil"&gt;GitHub Sponsors&lt;/a&gt; or buy me a coffee
on &lt;a href="https://ko-fi.com/danvratil"&gt;Ko-fi&lt;/a&gt; (after all, more coffee means more code, right?).&lt;/p&gt;</content></entry><entry><title>Rust: linking static C/C++ libraries with LTO</title><link rel="alternate" href="https://dvratil.cz/2025/12/rust-linking-static-c/c-libraries-with-lto/"/><id>https://dvratil.cz/2025/12/rust-linking-static-c/c-libraries-with-lto/</id><published>2025-12-16T23:00:00+0100</published><updated>2025-12-16T23:00:00+0100</updated><category term="Rust"/><summary>&lt;h2 id="the-backstory"&gt;The Backstory&lt;/h2&gt;
&lt;p&gt;I wasted entire afternoon today trying to figure this out, so here&amp;rsquo;s a quick note for future reference - hopefully to save someone else&amp;rsquo;s afternoon.&lt;/p&gt;
&lt;p&gt;Today, I was working on adding Rust bindings for an internal C++ library. The C++ library itself is built using CMake and produces a statically-linked library, let&amp;rsquo;s call it &lt;em&gt;libfoo.a&lt;/em&gt;.
I used the &lt;a href="https://cxx.rs/"&gt;&lt;code&gt;cxx&lt;/code&gt;&lt;/a&gt; crate to generate the glue code between Rust and the C++ library, wrote the higher-level Rust API and ran &lt;code&gt;cargo build&lt;/code&gt;. The crate built just fine, so I moved on to integrating it into our larger Rust project. However, when I tried to build the project, I got a linker error:&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/2025/12/rust-linking-static-c/c-libraries-with-lto/">&lt;h2 id="the-backstory"&gt;The Backstory&lt;/h2&gt;
&lt;p&gt;I wasted entire afternoon today trying to figure this out, so here&amp;rsquo;s a quick note for future reference - hopefully to save someone else&amp;rsquo;s afternoon.&lt;/p&gt;
&lt;p&gt;Today, I was working on adding Rust bindings for an internal C++ library. The C++ library itself is built using CMake and produces a statically-linked library, let&amp;rsquo;s call it &lt;em&gt;libfoo.a&lt;/em&gt;.
I used the &lt;a href="https://cxx.rs/"&gt;&lt;code&gt;cxx&lt;/code&gt;&lt;/a&gt; crate to generate the glue code between Rust and the C++ library, wrote the higher-level Rust API and ran &lt;code&gt;cargo build&lt;/code&gt;. The crate built just fine, so I moved on to integrating it into our larger Rust project. However, when I tried to build the project, I got a linker error:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;note: rust-lld: error: undefined symbol: url_to_json[abi:cxx11](std::basic_string_view&amp;lt;char, std::char_traits&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I double-checked the &lt;code&gt;build.rs&lt;/code&gt; script of the bindings crate to ensure that &lt;em&gt;libfoo.a&lt;/em&gt; was being linked. It was. I then used &lt;code&gt;nm&lt;/code&gt; to confirm that the symbol actually exists in &lt;em&gt;libfoo.a&lt;/em&gt;. It did. So what now? I spent a lot of time googling around, trying different &amp;ldquo;hacks&amp;rdquo; in the build.rs script and other sorcery. I had a temporary success by adding complex &lt;code&gt;build.rs&lt;/code&gt; into the consumer project, but that wasn&amp;rsquo;t really a scalable solution.&lt;/p&gt;
&lt;p&gt;The most confusing part was that I used the exact same approach and code to create bindings for another our C++ library a while ago, and there it all just worked. No special linker flags, no magical cargo incantations, no &lt;code&gt;build.rs&lt;/code&gt; in projects that used the bindings crate. What was different this time?&lt;/p&gt;
&lt;h2 id="a-suspect-is-identified"&gt;A Suspect is Identified&lt;/h2&gt;
&lt;p&gt;After literally hours of trial and error and out of desperation, I decided to &lt;code&gt;objdump&lt;/code&gt; the &lt;em&gt;libfoo.a&lt;/em&gt; to look at the disassembly of the problematic &lt;code&gt;url_to_json&lt;/code&gt; function. I am far from an assembly expert, but the disassembled output looked very suspicious, even to my untrained eye.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;0000000000000000 &amp;lt;.gnu.lto__Z11url_to_jsonB5cxx11RKSt17basic_string_viewIcSt11char_traitsIcEE.1350.d0d92fceb60052fc&amp;gt;:
0: 28 b5 2f fd 60 72 sub %dh,0x7260fd2f(%rbp)
6: 02 25 12 00 b6 a0 add -0x5f49ffee(%rip),%ah
c: 71 46 jno 54 &amp;lt;.gnu.lto__Z11url_to_jsonB5cxx11RKSt17basic_string_viewIcSt11char_traitsIcEE.1350.d0d92fceb60052fc+0x54&amp;gt;
e: e0 d0 loopne ffffffffffffffe0
10: 36 1d f8 c7 f0 69 ss sbb $0x69f0c7f8,%eax
16: 6c insb (%dx),%es:(%rdi)
17: 81 05 c4 c0 e0 96 61 addl $0x149c4e61,-0x691f3f3c(%rip)
1e: 4e 9c 14
21: a0 ad c0 3f f4 3e de movabs 0x102dde3ef43fc0ad,%al
28: 2d 10
2a: a4 movsb %ds:(%rsi),%es:(%rdi)
2b: 61 (bad)
(truncated)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Those instructions don&amp;rsquo;t look sensible at all, especially when compared to what the actual C++ code looks like. And what about the &amp;ldquo;bad&amp;rdquo; instruction? It&amp;rsquo;s not like I haven&amp;rsquo;t run into miscompilations before, but this was much more than that.&lt;/p&gt;
&lt;p&gt;At this point, I consulted the situation with an AI, and the answer was clear:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When working with static libraries and Clang, issues with assembly output from tools like objdump can arise, particularly when Link-Time Optimization (LTO) is enabled.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Wait! Did it say LTO? The static library is definitely built with LTO (it&amp;rsquo;s even in the name of the symbol). Quick check into the library&amp;rsquo;s CMakeLists.txt and bingo: LTO is enabled by default. I disabled it and&amp;hellip;the consumer project built and linked without a single error. Problem solved.&lt;/p&gt;
&lt;h2 id="butwhy"&gt;But&amp;hellip;why?&lt;/h2&gt;
&lt;p&gt;My (shallow) understanding of LTO has always been that it&amp;rsquo;s just a special optimizer pass at link time, when the linker can see the final executable (or shared library) as a whole, and can perform optimizations across translation units and more efficiently eliminate unused code. A static library is just a collection of object files, so LTO should not really play any role here, right?&lt;/p&gt;
&lt;p&gt;The reality is that with LTO enabled, compilers &amp;ldquo;cheat&amp;rdquo; (yes, compiler&lt;strong&gt;s&lt;/strong&gt; - GCC does this as well), and instead of producing object files with the final machine code, they produce object-like files that contain the intermediate representation (IR) of the code. IR (GCC calls it GIR) is a compiler-specific representation of the code during the compilation process. It&amp;rsquo;s no longer the original source code, but it&amp;rsquo;s not the final machine code either. Having access to the IR allows the linker to perform advanced optimizations that wouldn&amp;rsquo;t be possible if it only had access to the final machine code. The final codegen that emits the executable machine code happens after the optimization pass.&lt;/p&gt;
&lt;p&gt;This entire process is actually described quite nicely in the &lt;a href="https://llvm.org/docs/LinkTimeOptimization.html"&gt;LLVM documentation about LTO&lt;/a&gt; - which is an information that is useful only when you know that you need it :-)&lt;/p&gt;
&lt;p&gt;However, if the &lt;em&gt;libfoo.a&lt;/em&gt; contained LLVM IR, and rustc also uses LLVM (and supports LTO on its own), why didn&amp;rsquo;t it Just Work™? The problem is that Rust will only perform LTO between Rust crates by default.&lt;/p&gt;
&lt;h2 id="cross-language-lto-with-cxx"&gt;Cross-language LTO with &lt;code&gt;cxx&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Luckily, it&amp;rsquo;s possible to coerce the Rust compiler to perform cross-language LTO, but if you are using the &lt;code&gt;cxx&lt;/code&gt; crate, there&amp;rsquo;s an extra step involved.&lt;/p&gt;
&lt;p&gt;This is what ultimately worked for me, and allowed me to build both without LTO in debug mode and with LTO in release mode.&lt;/p&gt;
&lt;p&gt;In your &lt;code&gt;build.rs&lt;/code&gt;, you must make sure that the generated bridge code is also compiled with LTO enabled (when needed):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-rust" data-lang="rust"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; enable_lto &lt;span style="color:#f92672"&gt;=&lt;/span&gt; std::env::var(&lt;span style="color:#e6db74"&gt;&amp;#34;PROFILE&amp;#34;&lt;/span&gt;).unwrap_or_default() &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;release&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Compile the C++ library
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cmake::Config::new(&lt;span style="color:#e6db74"&gt;&amp;#34;.&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; .define(&lt;span style="color:#e6db74"&gt;&amp;#34;ENABLE_LTO&amp;#34;&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; enable_lto { &lt;span style="color:#e6db74"&gt;&amp;#34;ON&amp;#34;&lt;/span&gt; } &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt; { &lt;span style="color:#e6db74"&gt;&amp;#34;OFF&amp;#34;&lt;/span&gt; })
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; .build_target(&lt;span style="color:#e6db74"&gt;&amp;#34;all&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Build the cxx bridge
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;mut&lt;/span&gt; bridge &lt;span style="color:#f92672"&gt;=&lt;/span&gt; cxx_build::bridge(&lt;span style="color:#e6db74"&gt;&amp;#34;src/bridge.rs&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; .file(&lt;span style="color:#e6db74"&gt;&amp;#34;src/bridge.cpp&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// ... additional includes paths, source files, flags, etc.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; enable_lto {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Enable LTO for the bridge compilation as well
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; bridge.flag_if_supported(&lt;span style="color:#e6db74"&gt;&amp;#34;-flto&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bridge.compile(&lt;span style="color:#e6db74"&gt;&amp;#34;foo_bridge&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And to compile it. Just make sure you use Clang for building the C++ code as well (the &lt;code&gt;cc&lt;/code&gt; crate inside &lt;code&gt;cxx&lt;/code&gt; should pick this up automatically from the environment variables):&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# Make sure to use clang!
export CXX=clang++
export CC=clang
# Enable LTO linker plugin
export RUSTFLAGS=&amp;#34;-Clinker-plugin-lto&amp;#34;
# Let&amp;#39;s gooooo
cargo build --release
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;An important requirement is that the C/C++ code must be compiled with a version of Clang that is compatible with the LLVM version used by rustc. The compatibility matrix is &lt;a href="https://doc.rust-lang.org/rustc/linker-plugin-lto.html#toolchain-compatibility"&gt;documented in the rustc book&lt;/a&gt;. In my case, I was using rustc 1.90 (LLVM 20.1.8) and Clang 20.1.8.&lt;/p&gt;
&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;If you ever run into &lt;code&gt;undefined reference&lt;/code&gt; linker errors when trying to link static C or C++ libraries with your Rust code, double check whether the static library was built with LTO enabled, and make sure to enable cross-language LTO in your Rust build as well.&lt;/p&gt;</content></entry><entry><title>Old New Blog</title><link rel="alternate" href="https://dvratil.cz/2024/12/old-new-blog/"/><id>https://dvratil.cz/2024/12/old-new-blog/</id><published>2024-12-20T16:55:18+0100</published><updated>2024-12-20T16:55:18+0100</updated><category term="Random Blurbs"/><summary>&lt;p&gt;I started this blog back in 2010. Back then I used Wordpress and it worked reasonably well. In 2018 I decided to switch to a static generated site, mostly because the Wordpress blog felt slow to load and it was hassle to maintain. Back then the go-to static site generator was Jekyll, so I went with that. Lately I&amp;rsquo;ve been struggling with it though, because in order to keep all the plugins working, I needed to use older versions or Ruby, which meant I had to use Docker to build the blog locally. Overall, it felt like too much work and for the past few years I&amp;rsquo;ve been eyeing Hugo - more so since Carl and others migrated most of KDE websites to it. I mean, if it&amp;rsquo;s good enough for KDE, it&amp;rsquo;s good enough for me, right?&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/2024/12/old-new-blog/">&lt;p&gt;I started this blog back in 2010. Back then I used Wordpress and it worked reasonably well. In 2018 I decided to switch to a static generated site, mostly because the Wordpress blog felt slow to load and it was hassle to maintain. Back then the go-to static site generator was Jekyll, so I went with that. Lately I&amp;rsquo;ve been struggling with it though, because in order to keep all the plugins working, I needed to use older versions or Ruby, which meant I had to use Docker to build the blog locally. Overall, it felt like too much work and for the past few years I&amp;rsquo;ve been eyeing Hugo - more so since Carl and others migrated most of KDE websites to it. I mean, if it&amp;rsquo;s good enough for KDE, it&amp;rsquo;s good enough for me, right?&lt;/p&gt;
&lt;p&gt;So this year I finally got around to do the switch. I migrated all the content from Jekyll. This time I actually went through every single post, converted it to proper Markdown, fixed formatting, images etc. It was a nice trip down the memory lane, reading all the old posts, remembering all the sprints and Akademies&amp;hellip; I also took the opportunity to clean up the tags and categories, so that they are more consistent and useful.&lt;/p&gt;
&lt;p&gt;Finally, I have rewritten the theme - I originally ported the template from Wordpress to Jekyll, but it was a bit of a mess, responsivity was &amp;ldquo;hacked&amp;rdquo; in via JavaScript. Web development (and my skills) has come a long way since then, so I was able to leverage more modern CSS and HTML features to make the site look the same, but be more responsive and accessible.&lt;/p&gt;
&lt;h2 id="comments"&gt;Comments&lt;/h2&gt;
&lt;p&gt;When I switched from Wordpress to Jekyll, I was looking for a way to preserve comments. I found &lt;a href="https://isso-comments.de/"&gt;Isso&lt;/a&gt;, which is basically a small CGI server backed with SQLite that you can run on the server and embed it into your static website through JavaScript. It could also natively import comments from Wordpress, so that&amp;rsquo;s the main reason why I went with it, I think. Isso was not perfect (although the development has picked up again in the past few years) and it kept breaking for me. I think it haven&amp;rsquo;t worked for the past few years on my blog and I just couldn&amp;rsquo;t be bothered to fix it. So, I decided to ditch it in favor of another solution&amp;hellip;&lt;/p&gt;
&lt;p&gt;I wanted to keep the comments for old posts by generating them as static HTML from the Isso&amp;rsquo;s SQLite database, alas the database file was empty. Looks like I lost all comments at some point in 2022. It sucks, but I guess it&amp;rsquo;s not the end of the world. Due to the nature of how Isso worked, not even the Wayback Machine was able to archive the comments, so I guess they are lost forever&amp;hellip;&lt;/p&gt;
&lt;p&gt;For this new blog, I decided to use Carl&amp;rsquo;s approach with &lt;a href="https://carlschwan.eu/2020/12/29/adding-comments-to-your-static-blog-with-mastodon/" title="Carl Schwan - Adding comments to your static blog with Mastodon"&gt;embedding replies to a Mastodon&lt;/a&gt;. I think it&amp;rsquo;s a neat idea and it&amp;rsquo;s probably the most reliable solution for comments on a static blog (that I don&amp;rsquo;t have to pay for, host myself or deal with privacy concerns or advertising).&lt;/p&gt;
&lt;p&gt;I have some more ideas regarding the comments system, but that&amp;rsquo;s for another post ;-) Hopefully I&amp;rsquo;ll get to blog more often now that I have a shiny new blog!&lt;/p&gt;
&lt;h2 id="happy-holidays-"&gt;Happy Holidays 🎄&lt;/h2&gt;
&lt;p&gt;Enjoy the holidays and see you in 2025 🥳!&lt;/p&gt;</content></entry><entry><title>QCoro 0.11.0 Release Announcement</title><link rel="alternate" href="https://dvratil.cz/2024/10/qcoro-0.11.0-release-announcement/"/><id>https://dvratil.cz/2024/10/qcoro-0.11.0-release-announcement/</id><published>2024-10-04T12:00:00+0000</published><updated>2024-10-04T12:00:00+0000</updated><category term="QCoro"/><summary>&lt;!--
SPDX-FileCopyrightText: 2024 Daniel Vrátil &lt;dvratil@kde.org&gt;
SPDX-License-Identifier: GFDL-1.3-or-later
--&gt;
&lt;p&gt;A long over-due release which has accumulated a bunch of bugfixes but also some
fancy new features&amp;hellip;read on!&lt;/p&gt;
&lt;p&gt;As always, big thanks to everyone who reported issues and contributed to QCoro.
Your help is much appreciated!&lt;/p&gt;
&lt;h2 id="qcorolazytaskt"&gt;&lt;code&gt;QCoro::LazyTask&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The biggest new features in this release is the brand-new &lt;a href="https://qcoro.dev/reference/coro/lazytask"&gt;&lt;code&gt;QCoro::LazyTask&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/a&gt;.
It&amp;rsquo;s a new return type that you can use for your coroutines. It differs from &lt;code&gt;QCoro::Task&amp;lt;T&amp;gt;&lt;/code&gt;
in that, as the name suggest, the coroutine is evaluated lazily. What that means is when
you call a coroutine that returns &lt;code&gt;LazyTask&lt;/code&gt;, it will return imediately without executing
the body of the coroutine. The body will be executed only once you &lt;code&gt;co_await&lt;/code&gt; on the returned
&lt;code&gt;LazyTask&lt;/code&gt; object.&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/2024/10/qcoro-0.11.0-release-announcement/">&lt;!--
SPDX-FileCopyrightText: 2024 Daniel Vrátil &lt;dvratil@kde.org&gt;
SPDX-License-Identifier: GFDL-1.3-or-later
--&gt;
&lt;p&gt;A long over-due release which has accumulated a bunch of bugfixes but also some
fancy new features&amp;hellip;read on!&lt;/p&gt;
&lt;p&gt;As always, big thanks to everyone who reported issues and contributed to QCoro.
Your help is much appreciated!&lt;/p&gt;
&lt;h2 id="qcorolazytaskt"&gt;&lt;code&gt;QCoro::LazyTask&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The biggest new features in this release is the brand-new &lt;a href="https://qcoro.dev/reference/coro/lazytask"&gt;&lt;code&gt;QCoro::LazyTask&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/a&gt;.
It&amp;rsquo;s a new return type that you can use for your coroutines. It differs from &lt;code&gt;QCoro::Task&amp;lt;T&amp;gt;&lt;/code&gt;
in that, as the name suggest, the coroutine is evaluated lazily. What that means is when
you call a coroutine that returns &lt;code&gt;LazyTask&lt;/code&gt;, it will return imediately without executing
the body of the coroutine. The body will be executed only once you &lt;code&gt;co_await&lt;/code&gt; on the returned
&lt;code&gt;LazyTask&lt;/code&gt; object.&lt;/p&gt;
&lt;p&gt;This is different from the behavior of &lt;code&gt;QCoro::Task&amp;lt;T&amp;gt;&lt;/code&gt;, which is eager, meaning that it will
start executing the body immediately when called (like a regular function call).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;LazyTask&lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; myWorker()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; qDebug() &lt;span style="color:#f92672"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Starting worker&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;co_return&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;42&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;Task&lt;span style="color:#f92672"&gt;&amp;lt;&amp;gt;&lt;/span&gt; mainCoroutine()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; qDebug() &lt;span style="color:#f92672"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Creating worker&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;auto&lt;/span&gt; task &lt;span style="color:#f92672"&gt;=&lt;/span&gt; myWorker();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; qDebug() &lt;span style="color:#f92672"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Awaiting on worker&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;auto&lt;/span&gt; result &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; task;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// do something with the result
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will result in the following output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-plain" data-lang="plain"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mainCoroutine(): Creating worker
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mainCoroutine(): Awaiting on worker
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;myWorker(): Starting worker
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If &lt;code&gt;myWorker()&lt;/code&gt; were a &lt;code&gt;QCoro::Task&amp;lt;T&amp;gt;&lt;/code&gt; as we know it, the output would look like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-plain" data-lang="plain"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mainCoroutine(): Creating worker
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;myWorker(): Starting worker
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mainCoroutine(): Awaiting on worker
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The fact that the body of a &lt;code&gt;QCoro::LazyTask&amp;lt;T&amp;gt;&lt;/code&gt; coroutine is only executed when &lt;code&gt;co_await&lt;/code&gt;ed has one
very important implication: &lt;strong&gt;it must not be used for Qt slots&lt;/strong&gt;, &lt;code&gt;Q_INVOKABLE&lt;/code&gt;s or, in general, for any
coroutine that may be executed directly by the Qt event loop. The reason is, that the Qt event loop
is not aware of coroutines (or QCoro), so it will never &lt;code&gt;co_await&lt;/code&gt; on the returned &lt;code&gt;QCoro::LazyTask&lt;/code&gt;
object - which means that the code inside the coroutine would never get executed. This is the
reason why the good old &lt;code&gt;QCoro::Task&amp;lt;T&amp;gt;&lt;/code&gt; is an eager coroutine - to ensure the body of the coroutine
gets executed even when called from the Qt event loop and not &lt;code&gt;co_await&lt;/code&gt;ed.&lt;/p&gt;
&lt;p&gt;For more details, see the &lt;a href="https://qcoro.dev/reference/coro/lazytask"&gt;documentation of &lt;code&gt;QCoro::LazyTask&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="defined-semantics-for-awaiting-default-constructed-and-moved-from-tasks"&gt;Defined Semantics for Awaiting Default-Constructed and Moved-From Tasks&lt;/h2&gt;
&lt;p&gt;This is something that wasn&amp;rsquo;t clearely defined until now (both in the docs and in the code), which is
what happens when you try to &lt;code&gt;co_await&lt;/code&gt; on a default-constructed &lt;code&gt;QCoro::Task&amp;lt;T&amp;gt;&lt;/code&gt; (or &lt;code&gt;QCoro::LazyTask&amp;lt;T&amp;gt;&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;Task&lt;span style="color:#f92672"&gt;&amp;lt;&amp;gt;&lt;/span&gt;(); &lt;span style="color:#75715e"&gt;// will hang indefinitely!
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Previously this would trigger a &lt;code&gt;Q_ASSERT&lt;/code&gt; in debug build and most likely a crash in production build.
Starting with QCoro 0.11, awaiting such task will print a &lt;code&gt;qWarning()&lt;/code&gt; and will hang indefinitely.&lt;/p&gt;
&lt;p&gt;The same applies to awaiting a moved-from task, which is identical to a default-constructed task:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;LazyTask&lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; task &lt;span style="color:#f92672"&gt;=&lt;/span&gt; myTask();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;handleTask(std&lt;span style="color:#f92672"&gt;::&lt;/span&gt;move(task));
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; task; &lt;span style="color:#75715e"&gt;// will hang indefinitely!`
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="compiler-support"&gt;Compiler Support&lt;/h2&gt;
&lt;p&gt;We have dropped official support for older compilers. Since QCoro 0.11, the officially supported compilers are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GCC &amp;gt;= 11&lt;/li&gt;
&lt;li&gt;Clang &amp;gt;= 15&lt;/li&gt;
&lt;li&gt;MSVC &amp;gt;= 19.40 (Visual Studio 17 2022)&lt;/li&gt;
&lt;li&gt;AppleClang &amp;gt;= 15 (Xcode 15.2)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;QCoro might still compile or work with older versions of those compilers, but we no longer test it and
do not guarantee that it will work correctly.&lt;/p&gt;
&lt;p&gt;The reason is that coroutine implementation in older versions of GCC and clang were buggy and behaved differently
than they do in newer versions, so making sure that QCoro behaves correctly across wide range of compilers was
getting more difficult as we implemented more and more complex and advanced features.&lt;/p&gt;
&lt;h2 id="other-features-and-changes"&gt;Other Features and Changes&lt;/h2&gt;
&lt;p&gt;A coroutine-friendly version of &lt;a href="https://doc.qt.io/qt-6/qfuture.html#takeResult"&gt;&lt;code&gt;QFuture::takeResult()&lt;/code&gt;&lt;/a&gt; is now available in the
form of &lt;a href="https://qcoro.dev/reference/core/qfuture#takeResult"&gt;&lt;code&gt;QCoroFuture::takeResult()&lt;/code&gt;&lt;/a&gt; when building QCoro against Qt 6 (&lt;a href="https://github.com/danvratil/qcoro/issues/217"&gt;#217&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;QCoro::waitFor(QCoro::Task&amp;lt;T&amp;gt;)&lt;/code&gt; no longer requires that the task return type &lt;code&gt;T&lt;/code&gt; is default-constructible (&lt;a href="https://github.com/danvratil/qcoro/pulls/223"&gt;#223&lt;/a&gt;, Joey Richey)&lt;/p&gt;
&lt;h2 id="bugfixes"&gt;Bugfixes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Suppress Clang error when building against Android NDK &amp;lt;= 25 (&lt;a href="https://github.com/danvratil/qcoro/issues/204"&gt;#204&lt;/a&gt;, Daniel Vrátil)&lt;/li&gt;
&lt;li&gt;Fixed missing QtGui dependency in QCoroQuick module (&lt;a href="https://github.com/danvratil/qcoro/pulls/209"&gt;#209&lt;/a&gt;, Andreas Sturmlechner)&lt;/li&gt;
&lt;li&gt;Fixed &lt;code&gt;QCoroIODevice::write()&lt;/code&gt; always returning 0 instead of bytes written (&lt;a href="https://github.com/danvratil/qcoro/issues/211"&gt;#211&lt;/a&gt;, Daniel Vrátil)&lt;/li&gt;
&lt;li&gt;Fixed unchecked &lt;code&gt;std::optional&lt;/code&gt; access in &lt;code&gt;QCoroIODevice::write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Fixed awaiting on signal emission with &lt;code&gt;qCoro()&lt;/code&gt; would resume the awaiter in the sender&amp;rsquo;s thread context (&lt;a href="https://github.com/danvratil/qcoro/issues/213"&gt;#213&lt;/a&gt;, Daniel Vrátil)&lt;/li&gt;
&lt;li&gt;Fixed build wilth clang 18 due to missing &lt;code&gt;#include &amp;lt;exception&amp;gt;&lt;/code&gt; (&lt;a href="https://github.com/danvratil/qcoro/pulls/220"&gt;#220&lt;/a&gt;, Micah Terhaar)&lt;/li&gt;
&lt;li&gt;Fixed crash when &lt;code&gt;QNetworkAccessManager&lt;/code&gt; is destroyed from a coroutine awaiting on a network reply (&lt;a href="https://github.com/danvratil/qcoro/issues/231"&gt;#231&lt;/a&gt;, Daniel Vrátil)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="full-changelog"&gt;Full changelog&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/danvratil/qcoro/releases/tag/v0.11.0"&gt;See changelog on Github&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="support"&gt;Support&lt;/h2&gt;
&lt;p&gt;If you enjoy using QCoro, consider supporting its development on &lt;a href="https://github.com/sponsors/danvratil"&gt;GitHub Sponsors&lt;/a&gt; or buy me a coffee
on &lt;a href="https://ko-fi.com/danvratil"&gt;Ko-fi&lt;/a&gt; (after all, more coffee means more code, right?).&lt;/p&gt;</content></entry><entry><title>KDE PIM Sprint 2024 Report</title><link rel="alternate" href="https://dvratil.cz/2024/06/kde-pim-sprint-2024-report/"/><id>https://dvratil.cz/2024/06/kde-pim-sprint-2024-report/</id><published>2024-06-19T20:00:00+0000</published><updated>2024-06-19T20:00:00+0000</updated><category term="kde"/><summary>&lt;p&gt;In 2021 I decided to &lt;a href="https://dvratil.cz/2021/05/taking-a-break/"&gt;take a break&lt;/a&gt; from contributing to KDE,
since I felt that I&amp;rsquo;ve been losing motivation and energy to contribute for a while…
But I&amp;rsquo;ve been slowly getting back to hacking on KDE stuff for the past year, which
ended in me going to Toulouse this year to attend the annual KDE PIM Sprint, my
first in 5 years.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m very happy to say that we have /a lot/ going on in PIM, and even though not
everything is in the best shape and the community is quite small (there were only
four of us at the sprint), we have great plans for the future, and I&amp;rsquo;m happy to be
part of it.&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/2024/06/kde-pim-sprint-2024-report/">&lt;p&gt;In 2021 I decided to &lt;a href="https://dvratil.cz/2021/05/taking-a-break/"&gt;take a break&lt;/a&gt; from contributing to KDE,
since I felt that I&amp;rsquo;ve been losing motivation and energy to contribute for a while…
But I&amp;rsquo;ve been slowly getting back to hacking on KDE stuff for the past year, which
ended in me going to Toulouse this year to attend the annual KDE PIM Sprint, my
first in 5 years.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m very happy to say that we have /a lot/ going on in PIM, and even though not
everything is in the best shape and the community is quite small (there were only
four of us at the sprint), we have great plans for the future, and I&amp;rsquo;m happy to be
part of it.&lt;/p&gt;
&lt;h1 id="day-0"&gt;Day 0&lt;/h1&gt;
&lt;p&gt;The sprint was officially supposed to start on Saturday, but everyone arrived already
on Friday, so why wait? We wrote down the topics to discuss, put them on a whiteboard
and got to it.&lt;/p&gt;
&lt;figure&gt;&lt;img src="/2024/06/kde-pim-sprint-2024-report/images/whiteboard.png"
alt="Whiteboard with all discussion topics"&gt;
&lt;/figure&gt;
&lt;p&gt;We&amp;rsquo;ve managed to discuss some pretty important topics - how we want to proceed with
deprecation and removal of some components, how to improve our test coverage or how
to improve indexing and much much more.&lt;/p&gt;
&lt;p&gt;I arrived to the sprint with two big topics to discuss: milestones and testing:&lt;/p&gt;
&lt;h2 id="milestones"&gt;Milestones&lt;/h2&gt;
&lt;p&gt;The idea is to create milestones for all our bigger efforts that we work (or want
to work) on. The milestones should be concrete goals that are achievable within a
reasonable time frame and have clear definition of done. Each milestones should then
be split to smaller tasks that can be tackled by individuals. We hope that this
will help to make KDE PIM more attractive to new contributors, who can now clearly
see what is being worked on and can find very concrete, bite-sized tasks to work
on.&lt;/p&gt;
&lt;p&gt;As a result, we took all the ongoing tasks and turned most of them into
&lt;a href="https://invent.kde.org/groups/pim/-/milestones"&gt;milestones in Gitlab&lt;/a&gt;. It&amp;rsquo;s still very much work in progress,
we still need to break down many milestones to smaller tasks, but the general ideas
are out there.&lt;/p&gt;
&lt;h2 id="e2e-testing-of-resources"&gt;E2E Testing of Resources&lt;/h2&gt;
&lt;p&gt;Akonadi Resources provide &amp;ldquo;bridge&amp;rdquo; between Akonadi Server and individual services,
like IMAP servers, DAV servers, Google Calendar etc. But we have no tests to verify
that our Resources can talk to the services and vice versa. The plan is to create
a testing framework (in Python) so that we can have automated nightly tests to
verify that e.g. IMAP resource interfaces properly with common IMAP server
implementations, including major proprietary ones like Gmail or Office365. We want
to achieve decent coverage for all our resources. This is a big project, but I think
it&amp;rsquo;s a very exciting one as it includes not just programming, but also figuring out
and building some infrastructure to run e.g. Dovecot, NextCloud and others in
a Docker to test against.&lt;/p&gt;
&lt;h1 id="day-1"&gt;Day 1&lt;/h1&gt;
&lt;p&gt;On Saturday we started quite early, all the delicious french pastry is not going to
eat itself, is it? After breakfast we continued with discussions, we dicussed tags
support, how to improve our PR. But we also managed to produce some code. I
implemented syncing of iCal categories with Akonadi tags, so the tags are becoming
more useful. I also prepared Akonadi to be cleanly handle planned deprecation and
retirement of KJots, KNotes and their acompanying resources, as well as planned
removal of the Akonadi Kolab Resource (in favor of using IMAP+DAV).&lt;/p&gt;
&lt;p&gt;One of the tasks I want to look into is improving how we do database transactions in
the Akonadi Server. To get some data out of it, I shoved Prometheus exporter into
Akonadi, hooked it up to a local Prometheus service, thrown together a Grafana
dashboard, and here we are:&lt;/p&gt;
&lt;figure&gt;&lt;img src="/2024/06/kde-pim-sprint-2024-report/images/grafana.png"
alt="Grafana dashboard"&gt;
&lt;/figure&gt;
&lt;p&gt;We decided to order some pizzas for dinner and stayed at the venue hacking until
nearly 11 o&amp;rsquo;clock.&lt;/p&gt;
&lt;h1 id="day-2"&gt;Day 2&lt;/h1&gt;
&lt;p&gt;On the last day of the sprint we wrapped up on the discussions and focused on actually
implementing some of the ideas. I spent most of the time extending the Migration agent
to extract tags from all existing events and todos already stored in Akonadi and helped
to create some of the milestones on the Gitlab board. We also came up with a plan for
KDE PIM BoF on this years Akademy, where we want to present out progress on the
respective milestones and to give a chance to contributors to learn what are the biggest
hurdles they are facing when trying to contribute to KDE PIM and how we can help make
it easier for them to get involved.&lt;/p&gt;
&lt;h1 id="conclusion"&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;I think it was a very productive sprint and I am really excited to be involved in PIM
again. Can&amp;rsquo;t wait to meet up with everyone again on Akademy in September.&lt;/p&gt;
&lt;p&gt;Go check out &lt;a href="https://ervin.ipsquad.net/blog/2024/06/16/report-from-kdepim-spring-sprint-2024/"&gt;Kevin&amp;rsquo;s&lt;/a&gt; and &lt;a href="https://carlschwan.eu/2024/06/16/kde-pim-sprint-2024-edition/"&gt;Carl&amp;rsquo;s&lt;/a&gt; reports to see what else
have they been up to during the sprint.&lt;/p&gt;
&lt;p&gt;Did some of the milestones caught your eye, or do you have have any questions? Come
talk to us in our &lt;a href="https://matrix.to/#/#kontact:kde.org"&gt;matrix channel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Finally, many thanks to Kevin for organizing the sprint,
&lt;a href="https://www.etincelle-coworking.com/"&gt;Étincelle Coworking&lt;/a&gt; for providing us with nice and spacious
venue and &lt;a href="https://ev.kde.org/"&gt;KDE e.V.&lt;/a&gt; for supporting us on travel.&lt;/p&gt;
&lt;p&gt;Finally, if you like such meetings to happen in the future so that we can push forward
your favorite software, please consider &lt;a href="https://www.kde.org/community/donations/index.php"&gt;making a tax-deductible donation&lt;/a&gt;
to the &lt;a href="https://ev.kde.org/"&gt;KDE e.V. foundation&lt;/a&gt;.&lt;/p&gt;</content></entry><entry><title>QCoro 0.10.0 Release Announcement</title><link rel="alternate" href="https://dvratil.cz/2023/12/qcoro-0.10.0-release-announcement/"/><id>https://dvratil.cz/2023/12/qcoro-0.10.0-release-announcement/</id><published>2023-12-05T21:30:00+0000</published><updated>2023-12-05T21:30:00+0000</updated><category term="QCoro"/><summary>&lt;!--
SPDX-FileCopyrightText: 2023 Daniel Vrátil &lt;dvratil@kde.org&gt;
SPDX-License-Identifier: GFDL-1.3-or-later
--&gt;
&lt;p&gt;Thank you to everyone who reported issues and contributed to QCoro.
Your help is much appreciated!&lt;/p&gt;
&lt;h2 id="support-for-awaiting-qt-signals-with-qprivatesignal"&gt;Support for awaiting Qt signals with QPrivateSignal&lt;/h2&gt;
&lt;p&gt;Qt has a feature where signals can be made &amp;ldquo;private&amp;rdquo; (in the sense that only class
that defines the signal can emit it) by appending &lt;code&gt;QPrivateSignal&lt;/code&gt; argument to the
signal method:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;MyObject&lt;/span&gt; &lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; QObject {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Q_OBJECT
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;...
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Q_SIGNALS:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; error(&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; code, &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; QString &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;message, QPrivateSignal);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;};
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;QPrivateSignal&lt;/code&gt; is a type that is defined inside the &lt;code&gt;Q_OBJECT&lt;/code&gt; macro, so it&amp;rsquo;s
private and as such only &lt;code&gt;MyObject&lt;/code&gt; class can emit the signal, since only &lt;code&gt;MyObject&lt;/code&gt;
can instantiate &lt;code&gt;QPrivateSignal&lt;/code&gt;:&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/2023/12/qcoro-0.10.0-release-announcement/">&lt;!--
SPDX-FileCopyrightText: 2023 Daniel Vrátil &lt;dvratil@kde.org&gt;
SPDX-License-Identifier: GFDL-1.3-or-later
--&gt;
&lt;p&gt;Thank you to everyone who reported issues and contributed to QCoro.
Your help is much appreciated!&lt;/p&gt;
&lt;h2 id="support-for-awaiting-qt-signals-with-qprivatesignal"&gt;Support for awaiting Qt signals with QPrivateSignal&lt;/h2&gt;
&lt;p&gt;Qt has a feature where signals can be made &amp;ldquo;private&amp;rdquo; (in the sense that only class
that defines the signal can emit it) by appending &lt;code&gt;QPrivateSignal&lt;/code&gt; argument to the
signal method:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;MyObject&lt;/span&gt; &lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; QObject {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Q_OBJECT
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;...
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Q_SIGNALS:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; error(&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; code, &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; QString &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;message, QPrivateSignal);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;};
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;QPrivateSignal&lt;/code&gt; is a type that is defined inside the &lt;code&gt;Q_OBJECT&lt;/code&gt; macro, so it&amp;rsquo;s
private and as such only &lt;code&gt;MyObject&lt;/code&gt; class can emit the signal, since only &lt;code&gt;MyObject&lt;/code&gt;
can instantiate &lt;code&gt;QPrivateSignal&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; MyObject&lt;span style="color:#f92672"&gt;::&lt;/span&gt;handleError(&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; code, &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; QString &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;message)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Q_EMIT &lt;span style="color:#a6e22e"&gt;error&lt;/span&gt;(code, message, QPrivateSignal{});
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;QCoro has a feature that makes it possible to &lt;code&gt;co_await&lt;/code&gt; a signal emission and
returns the signals arguments as a tuple:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;MyObject myObject;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;auto&lt;/span&gt; [code, message] &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; qCoro(&lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;myObject, &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;MyObject&lt;span style="color:#f92672"&gt;::&lt;/span&gt;handleError);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;While it was possible to &lt;code&gt;co_await&lt;/code&gt; a &amp;ldquo;private&amp;rdquo; signal previously, it would get
return the &lt;code&gt;QPrivateSignal&lt;/code&gt; value as an additional value in the result tuple
and on some occasions would not compile at all.&lt;/p&gt;
&lt;p&gt;In QCoro 0.10, we can detect the &lt;code&gt;QPrivateSignal&lt;/code&gt; argument and drop it inside QCoro
so that it does not cause trouble and does not clutter the result type.&lt;/p&gt;
&lt;p&gt;Achieving this wasn&amp;rsquo;t simple, as it&amp;rsquo;s not really possible to detect the type (because
it&amp;rsquo;s private), e.g. code like this would fail to compile, because we are not allowed
to refer to &lt;code&gt;Obj::QPrivateSignal&lt;/code&gt;, since that type is private to &lt;code&gt;Obj&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;template&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;typename&lt;/span&gt; T, &lt;span style="color:#66d9ef"&gt;typename&lt;/span&gt; Obj&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;constexpr&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;bool&lt;/span&gt; is_qprivatesignal &lt;span style="color:#f92672"&gt;=&lt;/span&gt; std&lt;span style="color:#f92672"&gt;::&lt;/span&gt;same_as_v&lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt;T, &lt;span style="color:#66d9ef"&gt;typename&lt;/span&gt; Obj&lt;span style="color:#f92672"&gt;::&lt;/span&gt;QPrivateSignal&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After many different attempts we ended up abusing &lt;code&gt;__PRETTY_FUNCTION__&lt;/code&gt;
(and &lt;code&gt;__FUNCSIG__&lt;/code&gt; on MSVC) and checking whether the function&amp;rsquo;s name contains
&lt;code&gt;QPrivateSignal&lt;/code&gt; string in the expected location. It&amp;rsquo;s a whacky hack, but hey - if it
works, it&amp;rsquo;s not stupid :). And thanks to improvements in compile-time evaluation in
C++20, the check is evaluated completely at compile-time, so there&amp;rsquo;s no runtime
overhead of obtaining current source location and doing string comparisons.&lt;/p&gt;
&lt;h2 id="source-code-reorganization-again"&gt;Source Code Reorganization (again!)&lt;/h2&gt;
&lt;p&gt;Big part of QCoro are template classes, so there&amp;rsquo;s a lot of code in headers. In my
opinion, some of the files (especially qcorotask.h) were getting hard to read and
navigate and it made it harder to just see the API of the class (like you get
with non-template classes), which is what users of a library are usually most
interested in.&lt;/p&gt;
&lt;p&gt;Therefore I decided to move definitions into separated files, so that they don&amp;rsquo;t
clutter the main include files.&lt;/p&gt;
&lt;p&gt;This change is completely source- and binary-compatible, so QCoro users don&amp;rsquo;t have
to make any changes to their code. The only difference is that the main QCoro
headers are much prettier to look at now.&lt;/p&gt;
&lt;h2 id="bugfixes"&gt;Bugfixes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;QCoro::waitFor()&lt;/code&gt; now re-throws exceptions (&lt;a href="https://github.com/danvratil/qcoro/issues/172"&gt;#172&lt;/a&gt;, Daniel Vrátil)&lt;/li&gt;
&lt;li&gt;Replaced deprecated &lt;code&gt;QWebSocket::error&lt;/code&gt; with &lt;code&gt;QWbSocket::errorOccured&lt;/code&gt; in QCoroWebSockets module (&lt;a href="https://github.com/danvratil/qcoro/pulls/174"&gt;#174&lt;/a&gt;, Marius P)&lt;/li&gt;
&lt;li&gt;Fix &lt;code&gt;QCoro::connect()&lt;/code&gt; not working with lambdas (&lt;a href="https://github.com/danvratil/qcoro/pulls/179"&gt;#179&lt;/a&gt;, Johan Brüchert)&lt;/li&gt;
&lt;li&gt;Fix library name postfix for qmake compatibilty (&lt;a href="https://github.com/danvratil/qcoro/pulls/192"&gt;#192&lt;/a&gt;, Shantanu Tushar)&lt;/li&gt;
&lt;li&gt;Fix &lt;code&gt;std::coroutine_traits isn't a class template&lt;/code&gt; error with LLVM 16 (&lt;a href="https://github.com/danvratil/qcoro/pulls/196"&gt;#196&lt;/a&gt;, Rafael Sadowski)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="full-changelog"&gt;Full changelog&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/danvratil/qcoro/releases/tag/v0.10.0"&gt;See changelog on Github&lt;/a&gt;&lt;/p&gt;</content></entry><entry><title>QCoro 0.8.0 Release Announcement</title><link rel="alternate" href="https://dvratil.cz/2023/01/qcoro-0.8.0-release-announcement/"/><id>https://dvratil.cz/2023/01/qcoro-0.8.0-release-announcement/</id><published>2023-01-31T19:53:00+0000</published><updated>2023-01-31T19:53:00+0000</updated><category term="QCoro"/><summary>&lt;!--
SPDX-FileCopyrightText: 2022 Daniel Vrátil &lt;dvratil@kde.org&gt;
SPDX-License-Identifier: GFDL-1.3-or-later
--&gt;
&lt;p&gt;This is a rather small release with only two new features and one small improvement.&lt;/p&gt;
&lt;p&gt;Big thank you to &lt;a href="https://xstrahl.com"&gt;Xstrahl Inc.&lt;/a&gt; who sponsored development of
new features included in this release and of QCoro in general.&lt;/p&gt;
&lt;p&gt;And as always, thank you to everyone who reported issues and contributed to QCoro.
Your help is much appreciated!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://qcoro.dvratil.cz/news/2023/2023-01-31-qcoro-0.8.0-announcement/"&gt;The original release announcement on qcoro.dvratil.cz&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="improved-qcorowaitfor"&gt;Improved &lt;code&gt;QCoro::waitFor()&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Up until this version, &lt;code&gt;QCoro::waitFor()&lt;/code&gt; was only usable for &lt;code&gt;QCoro::Task&amp;lt;T&amp;gt;&lt;/code&gt;.
Starting with QCoro 0.8.0, it is possible to use it with any type that satisfies
the &lt;code&gt;Awaitable&lt;/code&gt; concept. The concept has also been fixed to satisfies not just
types with the &lt;code&gt;await_resume()&lt;/code&gt;, &lt;code&gt;await_suspend()&lt;/code&gt; and &lt;code&gt;await_ready()&lt;/code&gt; member functions,
but also types with member &lt;code&gt;operator co_await()&lt;/code&gt; and non-member &lt;code&gt;operator co_await()&lt;/code&gt;
functions.&lt;/p&gt;</summary><content type="html" xml:base="https://dvratil.cz/2023/01/qcoro-0.8.0-release-announcement/">&lt;!--
SPDX-FileCopyrightText: 2022 Daniel Vrátil &lt;dvratil@kde.org&gt;
SPDX-License-Identifier: GFDL-1.3-or-later
--&gt;
&lt;p&gt;This is a rather small release with only two new features and one small improvement.&lt;/p&gt;
&lt;p&gt;Big thank you to &lt;a href="https://xstrahl.com"&gt;Xstrahl Inc.&lt;/a&gt; who sponsored development of
new features included in this release and of QCoro in general.&lt;/p&gt;
&lt;p&gt;And as always, thank you to everyone who reported issues and contributed to QCoro.
Your help is much appreciated!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://qcoro.dvratil.cz/news/2023/2023-01-31-qcoro-0.8.0-announcement/"&gt;The original release announcement on qcoro.dvratil.cz&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="improved-qcorowaitfor"&gt;Improved &lt;code&gt;QCoro::waitFor()&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Up until this version, &lt;code&gt;QCoro::waitFor()&lt;/code&gt; was only usable for &lt;code&gt;QCoro::Task&amp;lt;T&amp;gt;&lt;/code&gt;.
Starting with QCoro 0.8.0, it is possible to use it with any type that satisfies
the &lt;code&gt;Awaitable&lt;/code&gt; concept. The concept has also been fixed to satisfies not just
types with the &lt;code&gt;await_resume()&lt;/code&gt;, &lt;code&gt;await_suspend()&lt;/code&gt; and &lt;code&gt;await_ready()&lt;/code&gt; member functions,
but also types with member &lt;code&gt;operator co_await()&lt;/code&gt; and non-member &lt;code&gt;operator co_await()&lt;/code&gt;
functions.&lt;/p&gt;
&lt;h2 id="qcorosleepfor-and-qcorosleepuntil"&gt;&lt;code&gt;QCoro::sleepFor()&lt;/code&gt; and &lt;code&gt;QCoro::sleepUntil()&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Working both on QCoro codebase as well as some third-party code bases using QCoro
it&amp;rsquo;s clear that there&amp;rsquo;s a usecase for a simple coroutine that will sleep for
specified amount of time (or until a specified timepoint). It is especially useful
in tests, where simulating delays, especially in asynchronous code is common.&lt;/p&gt;
&lt;p&gt;Previously I used to create small coroutines like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;Task&lt;span style="color:#f92672"&gt;&amp;lt;&amp;gt;&lt;/span&gt; timer(std&lt;span style="color:#f92672"&gt;::&lt;/span&gt;chrono&lt;span style="color:#f92672"&gt;::&lt;/span&gt;milliseconds timeout) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; QTimer timer;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; timer.setSingleShot(true);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; timer.start(timeout);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; timer;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can do the same simply by using &lt;code&gt;QCoro::sleepFor()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Read the &lt;a href="https://qcoro.dvratil.cz/reference/core/qtimer/#qcorosleepfor"&gt;documentation for &lt;code&gt;QCoro::sleepFor()&lt;/code&gt;&lt;/a&gt;
and &lt;a href="https://qcoro.dvratil.cz/reference/core/qtimer/#qcorosleepuntil"&gt;&lt;code&gt;QCoro::sleepUntil()&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;
&lt;h2 id="qcoromovetothread"&gt;&lt;code&gt;QCoro::moveToThread()&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;A small helper coroutine that allows a piece of function to be executed in the context
of another thread.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; App&lt;span style="color:#f92672"&gt;::&lt;/span&gt;runSlowOperation(QThread &lt;span style="color:#f92672"&gt;*&lt;/span&gt;helperThread) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Still on the main thread
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ui&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;statusLabel.setText(tr(&lt;span style="color:#e6db74"&gt;&amp;#34;Running&amp;#34;&lt;/span&gt;));
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; QString input &lt;span style="color:#f92672"&gt;=&lt;/span&gt; ui&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;userInput.text();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;moveToThread(helperThread);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Now we are running in the context of the helper thread, the main thread is not blocked
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// It is safe to use `input` which was created in another thread
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; doSomeComplexCalculation(input);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Move the execution back to the main thread
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;co_await&lt;/span&gt; QCoro&lt;span style="color:#f92672"&gt;::&lt;/span&gt;moveToThread(&lt;span style="color:#66d9ef"&gt;this&lt;/span&gt;&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;thread&lt;/span&gt;());
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Runs on the main thread again
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ui&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;statusLabel.setText(tr(&lt;span style="color:#e6db74"&gt;&amp;#34;Done&amp;#34;&lt;/span&gt;));
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Read the &lt;a href="https://qcoro.dvratil.cz/reference/core/qthread#qcoromovetothread"&gt;documentation for &lt;code&gt;QCoro::moveToThread&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;
&lt;h2 id="full-changelog"&gt;Full changelog&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/danvratil/qcoro/releases/tag/v0.8.0"&gt;See changelog on Github&lt;/a&gt;&lt;/p&gt;</content></entry></feed>