Aurélien Gâteau

Using std::unique_ptr with Qt

written on Thursday, May 30, 2019

Qt memory handling

Qt has a well established way to handle memory management: any QObject-based instance can be made a child of another QObject instance. When the parent instance is deleted it deletes all its children. Simple and efficient.

When a Qt method takes a QObject pointer one can rely on the documentation to know if the function takes ownership of the pointer. Same thing for functions returning a QObject pointer.

What the rest of the world does

This is very Qt specific. In the rest of the C++ world, object ownership is more often managed through smart pointers like std::unique_ptr and std::shared_ptr.

I am used to the Qt way, but I like the harder to misuse and self documenting aspect of the unique_ptr way. Look at this simple function:

Engine* createEngine();

With this signature we have no way to know if you are expected to delete the new engine. And the compiler cannot help us. This code builds:

    Engine* engine = createEngine();
    // Memory leak!

With this signature, on the other hand:

std::unique_ptr<Engine> createEngine();

It is clear and hard to ignore that ownership is passed to the caller. This won't build:

    Engine* engine = createEngine();

But this builds and does not leak:

    std::unique_ptr<Engine> engine = createEngine();
    // No leak, Engine instance is deleted when going out of scope

(And we can use auto to replace the lengthy std::unique_ptr<Engine> declaration)

Nanonote 1.2.0

written on Sunday, May 12, 2019

Time for a new Nanonote release!


This new version comes with several changes from Daniel Laidig: you can now use Ctrl+mouse wheel to make the text bigger or smaller and Ctrl+0 to reset the font to its default size.

He also fixed the way links are displayed: they now use the theme color instead of being hard-coded to blue. If you use a dark theme, this should make Nanonote more usable for you.

Nanonote now speaks German, thanks to Vinzenz Vietzke.

Yokadi 1.2.0

written on Sunday, February 10, 2019

I just released version 1.2.0 of Yokadi, my command-line todo-list.

Nanonote 1.1.0

written on Monday, February 4, 2019

Several interesting changes landed in Nanonote recently, time to release version 1.1.0.

There are a few fancy indentation improvements: pressing Tab when the cursor is at the beginning of a list item now indents the whole line, making it fast to create sub lists. Thanks to Daniel Laidig for this contribution. Conversely, pressing Enter on an empty list item now unindents the line, then remove the list bullet.

URL detection has been improved to allow the +, % and ~ characters. This should greatly reduce the number of partially highlighted URLs.

The application is now available in Spanish and French, thanks to Victorhck for the Spanish translation.

Building Qt apps with Travis CI and Docker

written on Saturday, January 19, 2019

I recently configured Travis CI to build Nanonote, my minimalist note-taking application. We use Jenkins a lot at work, and despite the fact that I dislike the tool itself, it has proven invaluable in helping us catch errors early. So I strongly believe in the values of Continuous Integration.

Nanonote 1.0.1

written on Saturday, January 12, 2019

The first release of Nanonote, my minimalist note-taking app, was a bit rushed: I broke indentation shortly before tagging version 1.0.0... meh.

So here is version 1.0.1. It fixes the indentation and adds the ability to indent or unindent whole lines with Tab and Shift+Tab, in addition to the existing Ctrl+I and Ctrl+U shortcuts.

Release month, Nanonote 1.0.0

written on Sunday, December 30, 2018

Here is the last issue of release month! Today is the first release of Nanonote, a minimalist note-taking application.


Quoting the README:

It automatically saves anything you type in the screen on your disk. Being minimalist means it has no synchronisation, does not support multiple documents, images or any advanced formatting (the only formatting is highlighting urls). If you have long-lived notes you should store them in a more permanent place.

Release month, Burger Party 1.3.0!

written on Sunday, December 23, 2018

Another weekend, another release! This one is special. You may remember a few years ago I created a burger game for Android: Burger Party. At that time I had plans to generate some revenue through this game. After investigating the different revenue models, I sadly concluded I would have to include ads.

That did not work out (surprise!): at its peak Burger Party reached a few thousand installations, which generated a meager $30 of revenue. I guess the reasons for this failure was that: 1. There were not enough ads to make it work: I decided against permanent banners so the game only displayed interstitials between levels, and no more than one ad every two minutes, 2. It did not reach enough installations, marketing is not my forte.

I also never felt comfortable with the idea of one my personal projects being ad-based and proprietary. I kept telling myself I should remove the ads and release a new version of Burger Party as free software, but I never got around to do it...


Release month, qpropgen 0.1.1

written on Sunday, December 9, 2018

Continuing on this release month idea started last week, here is a release of another project. Today is the first release of qpropgen, a tool to generate QML-friendly QObject-based C++ classes from class definition files.