planetkde – -Wmarchttps://marcmutz.wordpress.com
Marc Mutz on Qt, Boost, and C++Tue, 26 Sep 2017 21:37:21 +0000enhourly1http://wordpress.com/https://s2.wp.com/i/buttonw-com.pngplanetkde – -Wmarchttps://marcmutz.wordpress.com
RFC: How to fix a tricky leak in QFormLayout?https://marcmutz.wordpress.com/2016/09/28/rfc-how-to-fix-a-tricky-leak-in-qformlayout/
https://marcmutz.wordpress.com/2016/09/28/rfc-how-to-fix-a-tricky-leak-in-qformlayout/#respondWed, 28 Sep 2016 08:17:25 +0000http://marcmutz.wordpress.com/?p=556]]>We have a nasty leak in QFormLayout::setWidget(). In setWidget(), we create the QWidgetItemV2 corresponding to the passed QWidget, and pass that on to Private::setItem, which has a bunch of error returns (guard clauses) that do not delete the item, among them negative row index and cell already occupied.

We could easily fix that missing delete, but this function is also used by setLayout(), say, where the item is the layout.

Conceptually deleting that item (= the nested layout) is completely OK, because the user should be able to rely on the form layout to take ownership of the nested layout, without ifs and buts.

But then we have code in tst_qformlayout that breaks. Simplified, it reads:

I guess you spot the problem? If l4 had been added, everything would’ve been peachy: The QHBoxLayout destructor unregistered itself from layout, which does not attempt to delete l4 when it itself is deleted.

But if l4 is not added for some reason, like in the test code above, the fixed code will attempt to delete l4, which is undefined behaviour, of course (double-delete).

I think such broken code deserves to be broken, for the greater good of fixing a resource leak. Esp. since a double-delete should complain much louder than a leak, and the API user can do something about the double-delete while she can’t do anything about the leak (the pointer is not reachable from outside QFormLayout).

I feel uneasy about adding this to 5.6 LTS, though, so I’ll make a minimal fix there, just for setWidget().

After the guys at Qt World Summit last year managed to mess up the recording of exactly one of the many, many talks there (my Effective Qt one, of course), this is to let you know that Jens Weller of Meeting C++ has uploaded the recording of my Effective Qt talk to his conference channel on YouTube.

I talk about Q_FOREACH vs. C++11 range-for, QLatin1String vs. QStringLiteral, as well as, of course, how bad QList is.

It’s a sum-up of the GoingNative 2012 conference that happened on Feb 2nd-3rd. There won’t be an English translation later, since it’d be outdated by the time it appeared. The talks are in English, and you can download them all from Microsoft’s Channel9 page, though.

Filed under: C++, C++0x, German, Heise Developer]]>https://marcmutz.wordpress.com/2012/02/10/heise-developer-goingnative-2012-gegenwart-und-zukunft-von-c/feed/0GoingNative12 @ KDAB, Berlinhttps://marcmutz.wordpress.com/2012/01/31/goingnative12-kdab-berlin/
https://marcmutz.wordpress.com/2012/01/31/goingnative12-kdab-berlin/#respondTue, 31 Jan 2012 15:36:26 +0000http://marcmutz.wordpress.com/?p=522]]>For everyone interested in C++11, and as suggested by Herb Sutter, KDAB will show the live stream of the GoingNative12 C++ conference in it’s training facilities at Tempelhofer Ufer 11 in Berlin this Thursday and Friday (Feb 2nd and 3rd). The show is scheduled to run from 18:30 to 02:15 (CET) each day. We invite everyone to join us, but please drop us a note at berlin(at)kdab.com so we can plan ahead.Filed under: C++0x, English, German]]>https://marcmutz.wordpress.com/2012/01/31/goingnative12-kdab-berlin/feed/0Wild Beastshttps://marcmutz.wordpress.com/2011/11/28/wild-beasts/
https://marcmutz.wordpress.com/2011/11/28/wild-beasts/#respondMon, 28 Nov 2011 10:35:13 +0000http://marcmutz.wordpress.com/?p=515]]>In “Private Practice: Taming Templates”, I had (deliberately, of course :)) hidden a bug in the implementation of KDGenericFactory. I’ve now added a discussion about the bug and its fix.Filed under: C++, English, Private Practice, Qt]]>https://marcmutz.wordpress.com/2011/11/28/wild-beasts/feed/0Private Practice: What’s in a Proxy-Style?https://marcmutz.wordpress.com/2011/11/24/private-practice-whats-in-a-proxy-style/
https://marcmutz.wordpress.com/2011/11/24/private-practice-whats-in-a-proxy-style/#respondThu, 24 Nov 2011 10:40:06 +0000http://marcmutz.wordpress.com/?p=509]]>A new session in the private practice, “What’s in a Proxy Style?”, examines QProxyStyle and derives some important caveat when applying a classical Design Pattern.

The first Private Practice article, Taming Templates, examines techniques to control template code bloat. There’s nothing particularly earth-shattering in there, but I noticed that a lot of people don’t seem to be aware of the fact that templates can cause a lot of duplicated code, so I thought I’d write about it.

Even if they haven’t been released under the Private Practice banner, the following articles also fit that category well:

Developing a serious and large application from scratch, or from an existing desktop application, presents a different set of challenges compared to your normal smart-phone ‘app’. Portability to different platforms, and long-term maintainability in the face of ever-changing mobile target platforms suddenly come into play. This paper attempts to summarize the experience we gathered using the new declarative GUI framework, QtQuick, in this project.

Unfortunately, recent events (read: Tizen) have already invalidated much of the content in the supplemental box on the future of Qt, but that’s the bane of everyone writing about Qt’s future these days…

Compared to the print version, we’ve updated the content in some places, such as spending less time on the removal of concepts and more about the adoption of the new standard, as well as turning the Top 10 into a Top 11 to celebrate the new standard