<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>C++ on KDE Blogs</title><link>https://blogs.kde.org/categories/c++/</link><description>Recent content in C++ on KDE Blogs</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Tue, 31 Mar 2026 18:04:10 +0300</lastBuildDate><atom:link href="https://blogs.kde.org/categories/c++/index.xml" rel="self" type="application/rss+xml"/><item><title>API documentation porting sprint</title><link>https://blogs.kde.org/2024/11/13/api-documentation-porting-sprint/</link><pubDate>Wed, 13 Nov 2024 00:00:00 +0000</pubDate><author>Farid Abdelnour</author><guid>https://blogs.kde.org/2024/11/13/api-documentation-porting-sprint/</guid><description>&lt;figure&gt;
 &lt;img class="img-fluid" src="https://blogs.kde.org/2024/11/13/api-documentation-porting-sprint/sprint-port-card.png"
 style="max-width: 100%; height: auto"
 /&gt;
&lt;/figure&gt;
&lt;p&gt;It was once said over the &lt;a href="https://mail.kde.org/pipermail/kde-devel/2024-July/002849.html"&gt;grapevine&lt;/a&gt; that: &amp;quot;Our C++ API documentation has some issues, our QML API documentation has a lot of issues.&amp;quot;&lt;/p&gt;
&lt;p&gt;And it was true, but that is to change soon! As you might know, there is an ongoing effort to &lt;a href="https://invent.kde.org/teams/documentation/sprints/-/boards"&gt;port our documentation&lt;/a&gt; from &lt;a href="https://www.doxygen.nl/"&gt;Doxygen&lt;/a&gt; to &lt;a href="https://doc.qt.io/qt-6/qdoc-index.html"&gt;QDoc&lt;/a&gt;, and you can help with that.&lt;/p&gt;
&lt;p&gt;This is a &lt;a href="https://invent.kde.org/teams/goals/streamlined-application-development-experience/-/issues/10"&gt;task&lt;/a&gt; that has been adopted by the &lt;a href="https://phabricator.kde.org/T17396"&gt;Streamlined Application Development Experience&lt;/a&gt; championed by &lt;a href="https://nicolasfella.de/"&gt;Nicolas Fella&lt;/a&gt; and &lt;a href="https://pointieststick.com/"&gt;Nate Graham&lt;/a&gt; as part of the &lt;a href="https://kde.org/goals/"&gt;KDE Goals&lt;/a&gt; initiative.&lt;/p&gt;
&lt;p&gt;We would like to invite you to join our porting sprint effort to finish this task. On &lt;strong&gt;November 14th at 1PM UTC&lt;/strong&gt;, we'll be hanging out in the &lt;a href="https://matrix.to/#/%23kde-streamlined-app-dev:kde.org"&gt;Matrix room&lt;/a&gt; working on this. Hope to see you there.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Some prerequisites:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ability to use a terminal&lt;/li&gt;
&lt;li&gt;Extra disk space (30GB minimum)&lt;/li&gt;
&lt;li&gt;Some familiarity with APIs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://invent.kde.org/teams/goals/streamlined-application-development-experience/-/issues/10#note_1052720"&gt;Check out the instructions&lt;/a&gt; prepared by &lt;a href="https://rabbitictranslator.com/"&gt;Thiago Sueto&lt;/a&gt; on how to get started porting a project to QDoc.&lt;/p&gt;</description></item><item><title>unique_ptr difference between libstdc++ and libc++ crashes your application</title><link>https://blogs.kde.org/2021/02/20/uniqueptr-difference-between-libstdc-and-libc-crashes-your-application/</link><pubDate>Sat, 20 Feb 2021 00:00:00 +0000</pubDate><author>David Faure</author><guid>https://blogs.kde.org/2021/02/20/uniqueptr-difference-between-libstdc-and-libc-crashes-your-application/</guid><description>&lt;p&gt;Thanks to the KDE FreeBSD CI, which runs our code on top of libc++, we discovered an interesting difference between libstdc++ and libc++'s implementation of unique_ptr. This is quite unexpected, and the actual result for users is even more unexpected: it can lead to crashes in specific situations. This happens when a widget -- using unique_ptr for its d pointer, as is customary these days -- installs an event filter. That event filter will be triggered during destruction of child widgets (at least for the QEvent::Destroy event, I've also seen it with QEvent::Leave events for instance). And, depending on how the event filter is written, it might use the d pointer of the widget, possibly before checking the event type. That's where it gets interesting: the libc++ implementation of unique_ptr sets it to null &lt;em&gt;before&lt;/em&gt; calling the destructor (because it's implemented in terms of &lt;tt&gt;reset(nullptr);&lt;/tt&gt;. In libstdc++ however, unique_ptr's destructor just calls the destructor, its value remains valid during destruction.&lt;/p&gt;
&lt;p&gt;Here's &lt;a href="http://www.davidfaure.fr/kde/unique_ptr_for_d_pointer.cpp"&gt;a testcase of the crash&lt;/a&gt;, extracted from the KIO code for which you can see the fix &lt;a href="https://invent.kde.org/frameworks/kio/-/commit/a8a2c08014484145a4bd2a541a1cbeb8be856bf1"&gt;here&lt;/a&gt;. It works with gcc/libstdc++, and crashes with clang/libc++, because MyWindow::eventFilter() is using a d pointer that is null already.
In this particular case the fix is easy, testing the event type before anything else. That's good practice anyway, for performance reasons. But there are &lt;a href="https://invent.kde.org/frameworks/kio/commit/3134b410b98e40b34d3b80d123ee1304f"&gt;other cases&lt;/a&gt;, where the situation was a bit different and the solution was to remove the event filter upon destruction.&lt;/p&gt;
&lt;p&gt;I like unique_ptr, but beware of the interaction with event filters...&lt;/p&gt;</description></item></channel></rss>