Leaky lambdas and self referencing shared pointers

After a bit of a debugging session, I ended up looking at some code in a large project

The connection gets removed when the pointer inside m_foo gets de-allocated by the shared_ptr.
But the connection target is a lambda that has captured a copy of the shared_ptr…

There is at least a couple of solutions.

  • Keep the connection object (QMetaObject::Connection) around and call disconnect in your destructor. That way the connection gets removed and the lamda object should get removed
  • Capture the shared pointer by (const) reference. Capture the shared pointer as a weak pointer. Or as a raw pointer. All of this is safe because whenever the shared pointer gets a refcount of zero, the connection gets taken down with the object.

I guess the lesson learnt is be careful when capturing shared pointers.

Posted in english, kde, qt

Let Qt models meet std::vector<std::tuple<…>>

The problem

So. I was stuck with a container of tuples that I wanted to see in a Qt view (QTableView, QtQuick ListView or similar). So how to do that?

Another problem: I haven’t been doing fun things with templates recently.

A solution?

After a bit of hacking, it seems like it can just be done like

and … tada:
QTableView

Of course, we are also QtQuick friendly

and a delegate containing the following

 

can give:
ListView

But enough about creation.

Whattabout manipulation?

Luckily we got you covered. Insert two extra rows at position 1?

Append a row?

Remove 2 rows at position 3?

Replace the underlying list?

Read-only looping over the elements?

The Qt model of course also accepts setData calls.

Future?

If anyone is interested I will polish the code a bit and publish it. If that’s the case, how should I name this thing?

And I did get around doing fun things with templates again.

Posted in english, kde, Pocket projects, qt

R is for Randa

This week I have been gathered with 38 KDE people in Randa, Switzerland. Randa is a place in a valley in the middle of the Alps close to various peaks like Matterhorn. It has been a week of intense hacking, bugfixing, brainstorming and a bit of enjoying the nature.

R is for Reproducible builds

I spent the first couple of days trying to get the Qt Documentation generation tool to reproducible generate documentation. Some of the fixes were of the usual ‘put data in an randomized datastructure, then iterate over it and create output’, where the fix is similar well known: Sort the datastructure first. Others were a bit more severe bugs that lead to the documentation to shuffle around the ‘obsolete’ bit, and the inheritance chains. Most of these fixes have been reviewed and submitted to the Qt 5.6 branch, one is still pending review, but that hopefully gets fixed soon. Then most of Qt (except things containing copies of (parts) of webkit and derivatives) should be reproducible.

R is for Roaming around in the mountains

Sleeping, hacking and dining in the same building sometimes leads to a enormous desire for fresh air. Luckily in the middle of the alps, it is readily available, and at least once a day many people went for a walk. To say hi to a sheep. Or to just go uphill until tired and then going back down. Or just finding a circle around. For this area, OpenStreetMap seems to have better maps than Google. We also went on a nice group trip to Zermatt and surroundings, sponsored by our friends in Edeltech.

R is for Releasing

One of the tasks I set myself for was to get my barcode generation library (prison. you know. being behind bars.) ready for release. A bit of api cleanup, including some future proofing, was done, and all users adapted. Hopefully it will be released as part of the next KDE Frameworks release.

R is for Reviewing code

When signing up for the sprint, one has to declare a couple of tasks to work on. One of the things I put myself up to was reviewing David Faure’s code changes. First, he is very productive, and second, he often gets into creating patches in code areas where many other contributors are scared to look. So someone has to do it, and code never scared me.

R is for Running

I planned on going running along the river monday, wednesday and friday. Fortunately that happened, but due to Switzerland having a bit more ups and downs than flat Denmark, it didn’t go that fast.

R is for Random bugfixing

When in the hacking mood surrounded by great developers, it is very easy to just fix minor bugs when you encounter them. There is likely someone around who knows the code in question. Or you are just in the mood to actually fix it, rather than living with a missing clock applet or a corner case crash.

R is for Rubber ducking

I am a brilliant person sized rubber duck. And I did get the opportunity to show off my skills a couple of times, as well as using some of the other people for that.

R is for Raising money

These sprints in Randa is only possible because of all the nice donations from people and companies around the world. The fundraiser is still running, and can be found at

Posted in debian, english, kde, qt

Randa day 0

Sitting on Lake Zurich and reflecting over things was a great way to get started. http://manifesta.org/2015/11/pavillon-of-reflections-for-zurich-in-2016/

After spending a bit of time in a train, I climbed part of a mountain together with Adriaan – up to the snow where I could throw a snowball at him. We also designed a couple of new frameworks on our climbing trip. Maybe they will be presented later.

Posted in english, kde

So close, but so far away

Posted in english, kde

Compilers and error messages

So. I typo’ed up some template code the other day. And once again I learned the importance of using several c++ compilers.

Here is a very reduced version of my code:

And let’s start with the compiler I was testing with first.

MSVC (2013 and 2015)

It is not completely clear from that error message what’s going on, so let’s try some other compilers:

GCC (4.9-5.3)

That’s pretty clear. More compilers:

Clang (3.3-3.7)

ICC (13)

(Yes. I mistyped the variable name used for decltype. Replacing the x with t makes it build).

Thanks to http://gcc.godbolt.org/ and http://webcompiler.cloudapp.net/ for testing with various compilers.

Posted in english, kde, qt

KDE at Qt World Summit

So. KDE has landed at Qt World Summit.

kdeboothqtws2015

You can come and visit our booth and …

  • hear about our amazing Free Qt Addons (KDE Frameworks)
  • stories about our development tools
  • meet some of our developers
  • Talk about KDE in general
  • Or just say hi!

KDE – 19 years of Qt Experience.

Posted in english, kde, qt

I accidentally the Debian menu

So quite some time ago, I filed this. After some going back and forth, it lead to this. And finally we have a conclusion. It took only two years, but now we are there. Let’s continue make Debian rock.

Posted in debian, english

Debconf 2015 – 7

The other day, the main talk was “Lets encrypt”, today it was “Let’s reproduce”

Posted in debian, english

Debconf 2015 – 6

There is more people with blue hair at Debconf than at an average Akademy. KDE – we need to do better :)

Posted in debian, english, kde