Language Selection

English French German Italian Portuguese Spanish

Kde Planet

Syndicate content Planet KDE
Planet KDE | English
Updated: 5 hours 28 min ago

October/November in KDE Itinerary

9 hours 27 min ago

Since the last summary KDE Itinerary has been moving with big steps towards the upcoming 21.12 release, with work on individual transport modes, more convenient ticket access, trip editing, a new health certificate UI, better transfer handling and many more improvements.

New Features Current ticket access

A small but very convenient new addition is the “Current ticket” action, which immediately navigates you to the details page of the most current element on the itinerary. That comes in handy when having to show or scan your ticket and avoids having to find the right entry in the list in a rush.

This action is now also accessible from jump list actions in the taskbar on Linux, or app shortcuts on Android. Combined with the easily accessible barcode scanmode mentioned last time it’s now just two clicks or taps to get ready for a ticket check.

Plasma task manager showing KDE Itinerary jump list actions. Trip shortening

KDE Itinerary so far provides only very limited editing capabilities for existing reservations, but one common case has now been added: shortening of train trips. That is, boarding later or leaving earlier along a booked journey, useful for example when having to react to service disruptions. Unlike general free-form editing, we can easily ensure in this case that the result remains a valid actually existing train connection, and thus all features requiring that remain functional.

Selecting an earlier exit from a train.

Realtime trip data is taken into account when available, and selecting canceled/skipped stations for boarding/leaving is prevented.

Health certificates

The health certificate UI has been restructured to use a tab bar instead of one long scrollable page. This is not just easier to navigate but separates the QR code from human readable details that a person scanning the code doesn’t necessarily need to see.

KDE Itinerary's new health certificate UI.

There is also support for a new certificate format, the Dutch COVID-19 CoronaCheck system. This one differs quite a bit from the formats supported so far as it’s much more optimized for privacy. The only information contained in the certificates are the user’s initials and day and month of birth, but no details about what actually has been certified (vaccine, recovery or test, etc).

Next to a paper-based variant which has a fairly long validity (and thus allows some guesses on how the certificate was obtained), the digital form provided by the official app generates very short-lived certificates to prevent tracking users across multiple scans. We can so far only provide an equivalent to the paper form, ie. the official app has still superior privacy features.

Infrastructure Work Individual transport modes

As mentioned in a previous post there has been ongoing work in KPublicTransport for supporting journey queries that combine public transport and individual transport modes.

That is interesting for a number of use-cases, such as driving to a station using your own bike or car and then parking it there (and thus requiring an appropriate parking space), taking your bike with you on the train (and thus requiring a train connection where that’s possible), or using rental vehicles like scooters for getting from a station to the final destination.

The data model of KPublicTransport supports this now, as do all its backends. The first bits of this also already show up in KDE Itinerary, for selecting transfers different individual transport modes can be chosen in the context menu.

Transfer selection context menu offering individual transport modes.

There’s a lot more to be done to nicely integrate this though, such as remembering the locations of the user’s vehicles and selecting appropriate modes automatically.

KDE Frameworks locale data

The previously discussed support for looking up and localizing country, country subdivision and timezone information in KDE Frameworks has finally landed with KF 5.88. This replaces older and less accurate or up-to-date code we used so far.

More interestingly this also enables a few new possibilities like informing about different currencies or local public holidays at travel destinations.

Fixes & Improvements Travel document extractor
  • Added new extractor scripts for the Pretix and gomus event ticketing systems.
  • Improved extractor scripts for Eurowings, Lufthansa, MÁV,
  • Fixed erroneous merging of train trips with the same line on the same day.
  • Incomplete location types in annotations are now extracted correctly.
  • The expirationDate field of Apple Wallet passes is now considered by the general pass extractor.
  • Event merging now also works for slightly differing reservations, e.g. due to different tickets for adults and children.
  • Sorting of flight reservations now also considers airport timezones when still missing exact arrival times.
  • KItinerary Workbench can now also show intermediate extractor results for each document node.
Public transport data
  • Attribution information for line or product logos are now provided, which enables using such logos under CC-BY licenses from Wikidata as well. This about doubles the amount of logos available.
  • Added a new UIC coach classification parser which is now used by all coach layout backends, improving detection of coach features especially for international trains.
  • The ÖBB coach layout backend has been ported to their new backend API.
  • Provider metadata can now also contain VDV organization identifiers, similar to what we already have for UIC company codes. This helps with selecting the best provider based on a given ticket.
  • Improve provider selection by preferring those containing both ends of a journey.
  • New OpenTripPlanner coverage area probing which produces more accurate coverage polygons when faced with outliers or otherwise inconsistent/corrupt data.
  • Improved product name parsing for Hafas, which in turn significantly improves merging with results from other sources.
  • Improved platform parsing for IVV ASS, providing platform information for trams as well in a number of places.
Indoor maps
  • Pinch zoom now finally works properly on phone touch screens.
  • Platform data aggregation and identification from OSM data now also considers IFOPT identifiers when present. This not only improves the platform list shown in the station maps, but also allows identification of tram or subway stop locations that don’t have a name, given the public transport data also contains an IFOPT identifier.
  • Improved Russian language support for parsing non-standard OSM opening hours expressions.
Itinerary app
  • PDF417 ticket barcodes can now be displayed, needed e.g. for the Hungarian railway (MÁV).
  • The context drawer is accessible again in the favorite location editor.
  • Transfer elements have the same progress and disruption highlights as regular reservation elements.
  • Automatic transfer selection picks more suitable options before a following departure.
  • Transfers are now considering realtime arrival/departure data of the reservations they are attached to.
  • Transfers to/from a favorite location now automatically select a nearby one.
  • Transfers can manually be added in more cases, such as around events or restaurant visits.
  • Transfers involving bikes or rental vehicles are now shown correctly.
  • Train or bus reservations now show their line or product icon in the timeline when available.
  • Bus reservations are now also monitored for delays.
  • Journey details can also be viewed for bus reservations when available.
  • When editing addresses of events, hotels or restaurants an automatic geo coordinate lookup can be triggered.
  • The location picker no longer closes itself when panning the map in the wrong way.
  • Icons in the timline elements are no longer randomly shown in smaller sizes.
  • Tooltips and accessibility hints were added in more places.
  • If you are not into flags, the statistics page can now also list the names of all visited countries.
  • The app now scales better to smaller screens.
KMail integration
  • Apple Wallet passes for events are no longer wrongly claimed to be boarding passes when attached to a calendar event.
  • Apple Wallet passes that don’t specify all required colors are no longer rendered unreadable in black on black.
Desktop integration
  • There’s a new KIO thumbnailer plug-in for Apple Wallet passes.

Feedback and travel document samples are very much welcome, but with travel remaining difficult there are plenty of other things that can be done as well of course. The KDE Itinerary workboard or the more specialized indoor map workboard show what’s on the todo list, and are a good place for collecting new ideas. For questions and suggestions, please feel free to join us on the KDE PIM mailing list or in the #kontact channel on Matrix.

KDE Devs Reacts to The Linux Experiment's Review of KDE Plasma

9 hours 28 min ago
Regarding the lag: as I say in the video, I switched to OBS but that means my computer is not able to live encode everything, thus the technical issues. Sorry about that, and I've bought a new laptop to address it!

This week in KDE: Fixing a bunch of annoying bugs

Saturday 27th of November 2021 06:00:06 AM

This was a major bug squashing week, with quite a lot of annoying issues fixed–some recent regressions, and many longstanding issues as well.

On the subject of bugs and recent regressions, I’m starting to think from a higher level about how we can prevent them. KDE has largely conquered our historical issues of excessive resource consumption and visual ugliness, and our next major challenge on the path towards world domination is reliability. One idea I’m toying with is starting an initiative to focus on the “15 minute bugs”–those embarrassing issues that can easily be found within just a few minutes of using the system normally. Here is a preliminary list of these issues in Plasma. I would encourage any experienced developers to try to focus on them! The impact will be very high.

Bugfixes & Performance Improvements

Creating archives using Ark’s main UI once again works (Kai Uwe Broulik, Ark 21.12)

Elisa no longer shows an error message instead of the number of tracks in the playlist footer when the playlist only has one track in it (Bharadwaj Raju, Elisa 21.12)

Okular’s zoom buttons now always enable and disable themselves at the correct times, in particular when a new document is opened (Albert Astals Cid, Okular 21.12)

Ark can now handle archives whose files internally use absolute paths, rather than relative paths (Kai Uwe Broulik, Ark 22.04)

Touch scrolling in Konsole now works properly (Henry Heino, Konsole 22.04)

Fixed a common crash in the System Tray (Fushan Wen, Plasma 5.23.4)

Fixed a common crash in Discover when using it to manage Flatpak apps (Aleix Pol Gonzalez, Plasma 5.23.4)

The logout screen once again has a blurred background and animates when appearing and disappearing (David Edmundson, Plasma 5.23.4)

In the Plasma Wayland session, dragging a file or folder from a Folder View popup into its parent folder no longer causes Plasma to crash (Marco Martin, Plasma 5.24)

In the Plasma Wayland session, when using a stylus, it’s now possible to activate other window from their titlebars and also just interact with titlebars more generally (Fushan Wen, Plasma 5.24)

Changing various settings in System Settings no longer causes a flickering effect behind Plasma panels (Vlad Zahorodnii, Plasma 5.24)

Repositioning a panel from horizontal to vertical or vice versa no longer causes the layout of the control strip to get kinda messed up (Fushan Wen, Plasma 5.24)

Activating the new Overview effect no longer causes auto-hidden panels to be shown (Vlad Zahorodnii, Plasma 5.24)

In the Plasma Wayland session, the Clipboard applet now shows entries for images added to the clipboard using the wl-copy command-line program (Méven Car, Plasma 5.24)

User Interface Improvements

Hovered and focused Breeze style scrollbars no longer blend in with their track so much (S. Christian Collins, Plasma 5.23.4)

Kate has been replaced with KWrite in the default set of favorite apps, since it’s a bit more user-friendly and less programmer-centric (me: Nate Graham, Plasma 5.24)

Discover’s somewhat confusing checkbox on the bottom of the Updates page has been transformed into a couple of buttons and a label which should be clearer, and it also doesn’t say the word “Updates” quite so many times on that page anymore (me: Nate Graham, Plasma 5.24):

When using PipeWire and streaming audio from one device to another, the audio stream now shows the name of the remote device in Plasma’s Audio Volume applet (Nicolas Fella, Plasma 5.24)

The Properties window for files now displays which app will open the file (Kai Uwe Broulik, Frameworks 5.89):

The icon selection dialog now pre-selects the folder’s currently-used icon for easier visualization and keyboard navigation (Kai Uwe Broulik, Frameworks 5.89)

Those little transient messages that sometimes appear at the bottom of the windows of Kirigami-based apps (which are nonsensically called “Toasts” in Android land) now have easier-to-read text (Felipe Kinoshita, Frameworks 5.89)

…And everything else

Keep in mind that this blog only covers the tip of the iceberg! Tons of KDE apps whose development I don’t have time to follow aren’t represented here, and I also don’t mention backend refactoring, improved test coverage, and other changes that are generally not user-facing. If you’re hungry for more, check out, where you can find blog posts by other KDE contributors detailing the work they’re doing.

How You Can Help

Have a look at to discover ways to be part of a project that really matters. Each contributor makes a huge difference in KDE; you are not a number or a cog in a machine! You don’t have to already be a programmer, either. I wasn’t when I got started. Try it, you’ll like it! We don’t bite!

Finally, consider making a tax-deductible donation to the KDE e.V. foundation.

New Icons, Iconoclast Pipeline

Friday 26th of November 2021 07:29:15 PM

Over the month of November work has been started to refresh the full-colour icons in Breeze as an extension of the “Blue Ocean” initiative. With literally hundreds of hand-created vector icons in our roster we’ve had to develop new processes and are working on a more robust pipeline so this refresh can be done in a somewhat timely manner.

Preview of the new folders. Subject to change and refinement.

As was the method for Blue Ocean on the desktop widgets and design, the icons will be a gradual rollout over a few releases. We do have a strategy in place to ensure that this won’t be too jarring or inconsistent during the transition. The current plan is to update both all mimetypes and all places in time for the 5.24 release.

Like our current icons the new icons have adaptive capabilities. Beyond that some additional select icons such as the new desktop icon are also adaptive, and there are plans for other icons to also take advantage of this feature where it would not be obnoxious. Compared to existing icons the refreshed content will be softer, more detailed, and less flat. These icons are also prepared with future capabilities in mind, and as enhancements are made to KDE Frameworks these icons may expose new and interesting features.

Finally, we’re expanding the number of sizes the icons come in, so they look ideal at more zoom levels in your file browser. Currently colour places icons are offered in 32, 48, 64, and 96 pixel sizes, and mimetypes are offered in 32 and 64 pixel sizes. Refreshed icons in both places and mimetypes will be offered in 32, 48, 64, 96, 128, and 256 pixel sizes with no missing graphics. We already have all folders in all of the above sizes, and in under a month while also writing our software we have over doubled the number of folder icons in Breeze. We’re estimating we will more than triple in the number of mimetype icons.

To get this work done we’ve built new tools for the express purpose of making mass iconography far easier for even individual artists, so I’m very pleased to state that a new icon and SVG pipeline is underway and despite being unfinished is producing results. This Python-written pipeline is capable of adding guides, rulers, and setting up grids for existing icons, standardizing existing icon colours, assembling entirely new icons from templates and components, and aggressively optimizing icons. With this authors will be able to have a “golden copy” of their icon sets where they can focus purely on design, letting the software take care of cleaning up the documents and assembling the individual pieces. The folders in the above image were assembled by the pipeline, with no hand-tuning.

In terms of optimization some extreme cases have seen unoptimized Oxygen icons drop 75% or their filesize. In less ideal situations a few simple hand-optimized test icons I produced run through the pipeline saw 10-20% reductions in filesize. The new optimizer is not built on any existing tools, and is an entirely new thing. At similar settings the new optimizer is on par or slightly ahead of Inkscape in most tests, but at the same time it’s also more specialized and the output cannot be edited when certain stages are enabled. It’s also targeted towards TinySVG and should not be expected to work on full-fat images (though, accommodations have been made). There is still work to be done too, and in the future more optimization steps are on the table to further reduce output size.

Not only is this pipeline beneficial to KDE artists, but history has proven even the roughest artistic tools we produce are regularly used outside of Plasma development. With this in mind we plan to release our new tooling separate from Breeze as its own package/download after polishing it to a mirror shine. Currently nicknamed “Iconoclast”, we are specifically setting out for this tooling to be useful and ready for the wider community beyond KDE.

Iconoclast will include our new pipeline, a manual, tips and advice, and another entirely new icon set named “Bones”, which is already in progress. The pipeline itself is strongly configurable with ini files, so KDE-isms can be removed and it can be adapted to work for icons sets that may have different flows through configuration. The Bones icon set will be a minimal base which can either be built on top of, or used as a reference, and these icons will released in the public domain. Different projects with different licenses can just take it and use it, and it’s uses generic technologies not tied to KDE. The pipeline itself will be GPL, and I don’t have a specific timeline for when the kit will be released but once it’s solidified I’ll make an announcement; though it’s likely to be after the new year.

Web Review, Week 2021-47

Friday 26th of November 2021 03:29:22 PM

Let’s go for my web review for the week 2021-47.

Your Fingerprint Can Be Hacked For $5. Here’s How. - Kraken Blog

Tags: tech, security

Good reminder of why fingerprint readers are really a poor security device.

The Handwavy Technobabble Nothingburger

Tags: tech, cryptoassets, scam

This is a good summary of why I think those crypto currencies are mainly a scam and used to entertain a perpetual delusion on their use.

The unbearable fussiness of the smart home - Stacey on IoT | Internet of Things news and analysis

Tags: tech, iot, smarthome

Feels like loosing agency in your own home… definitely not for me…

Flatpak Is Not the Future

Tags: tech, linux, flatpak

This is a bit of a rant but that summarizes quite well why I fail to fall in love with snap, flatpack and the likes. Everytime I tried to use one of those I ended up with GBs of extra runtime to deal with and the security arguments are frankly debatable… I wish the LSB wasn’t defunct.

Mobilizon v2, now matured, like a good French wine – Framablog

Tags: tech, web, framasoft

Really nice to see this excellent piece of software growing.

Git email flow vs Github flow

Tags: tech, git, email

Always wanted to try this particular way of dealing with patches. But none of the projects I contributed to so far work in that mode.

Django, HTMX and Alpine.js: Modern websites, JavaScript optional

Tags: tech, html, javascript, frontend, django

Interesting way to combine Django and a couple of JS based tiny frameworks to make simpler frontends.

Overengineering can kill your product - Mind the Product

Tags: tech, complexity

Good summary on why overengineering is bad, why it happens and how to try to prevent it. We deal with complexity we better make sure there’s no undue complexity in our systems.

The wording and bias of the article is a bit startup-y but most things in there apply more widely.

The Fingerprint Principle

Tags: management, change, improving

Interesting musing about change management: don’t come up with something too perfect if you want people to make it their own.

Bye for now!

How To Make Plasma Panel Fit Content (Like A Dock)!

Friday 26th of November 2021 10:45:12 AM

KDE Floating Panels: PULL REQUEST DONE! And Next Projects!

Thursday 25th of November 2021 11:10:57 AM

Where in the Stack?

Tuesday 23rd of November 2021 11:00:00 PM

For one of my projects – not KDE-related – I have a parser, written in YACC / bison. To build the project, the bison grammar needs to be compiled (by the bison command) to C, and then the C can be compiled to the final executable. On my workstation, the bison step would fail when the build was run one-process-at-a-time in KDE konsole. Workarounds were really weird: build with a -j flag to build with more processes at once, or pipe the build-output to cat, or run the build in xterm instead of konsole. So where is the bug? In konsole, in bison, or in something underneath? It’s definitely something to do with the terminal emulator: here’s a screenshot of bison compiling a sample file successfully in xterm, and crashing in konsole, roxterm and alacritty. It crashes in cool-retro-term as well, but leaves the terminal itself in a messed-up-state. It also crashes on the FreeBSD text console.

Five terminal windows with bison crashes

The output from bison, once piped to od -c – and then it does not crash – is intriguing. Here’s a part of the output:

0000120 ** ** , u s e ‘ ** ** % d e f i 0000140 n e a p i . p u r e ’ ** ** [ 0000160 033 [ 3 5 m 033 ] 8 ; i d = 5 b 1 f 0000200 0 f d 7 0 0 0 5 d 1 7 5 2 e 1 f 0000220 4 2 3 b 0 0 0 0 0 0 0 0 ; h t t 0000240 p s : / / w w w . g n u . o r g

This is colorized output, which uses the terminal-control sequences for xterm – there is a big long list of them – to manipulate colors and styles. Most terminal emulators understand these control sequences.

Huh, there’s a URL there. It doesn’t display in the terminal, though.

URL Highlighting in Konsole Konsole displaying URLs

Konsole has a neat feature where if you display a URL, it can be highlighted, and you can click on it from konsole to open the URL. That looks like the screenshot here; if it looks like a URL, it gets underlined when you mouse over it, and you can ctrl-click to open.

There is terminal-control sequence to hide a URL within terminal output. This uses the ESC ] 8 ; sequence (it probably has a name, but I haven’t been able to find it). By default, this is ignored, as a security measure: clicking on text in your text terminal should not invoke web browsers on invisible URLs. Konsole can turn the feature on, though: go to Settings -> Edit Current Profile -> Mouse -> Miscellaneous tab, then tick the box Allow escape sequences for links. Read the WARNING that is there, because it’s on-point.

You can use the printf command to construct this kind of terminal-control sequences. From the shell, something like this:

$ printf '\e]8;;\e\\GNOME\e]8;;\e\\\n' GNOME

Notice how the URL isn’t shown (it is the terminal emulator that handles that), but the text is. Notice, too, how the URL doesn’t match the text: that is what the security warning is all about.

This is actually pretty cool: bison prints a warning, and links from the warning message (which mentions a specific command-line flag) to the documentation which explains what the flag is for and provides additional context. It makes the warning message a bit more useful – if, and only if, that security-sensitive setting is on. (Which makes this cool feature from bison a lot less useful in most settings .. maybe GNOME terminal has a similar setting, but switched on by default).

OK, but looking at the bison output, specifically, there’s more than just a URL there: there is a id= part as well. Let’s add that to the printf command:

$ printf '\e]8;id=x;\e\\GNOME\e]8;;\e\\\n' GNOME

Up to, and including, KDE Gear 21.08.3 (the latest release as of this writing), konsole eats the terminal-control sequence, displays only the text, but now – after adding that id=x part – the URL is no longer recognized, and you can’t click on it.

I fixed this in konsole merge request #535. Konsole assumed that that id-part was empty, when clearly it isn’t (or at least, bison thinks it is reasonable to output something there).

Konsole bug, squashed

Bug, squashed! But .. bison still crashes.

Bison Warnings

I rebuilt bison with debugging enabled. Using gdb I found that the crash was invoked from warnings_print_categories(). The code looks like this:

const char *warning = argmatch_warning_argument (&w); char ref[200]; snprintf (ref, sizeof ref, "%s#W%s", diagnostics_url, warning); begin_hyperlink (out, ref); ostream_printf (errstream, "-W%s%s", s == severity_error ? "error=" : "", warning); end_hyperlink (out);

Bison is Free Software, copyrighted by the Free Software Foundation. The code above is licensed under the GPL Version 3.

I can see what it’s doing here: composing a URL and sending that to begin_hyperlink(), then printing the name of the warning itself, then calling end_hyperlink(). Unpacking each of those functions takes me to GNU libtextstyle which is part of GNU gettext. Bison, it turns out, isn’t doing anything strange, but something is going wrong lower down in the stack.

Libtextstyle Code

Since messing around with all of bison at once was a bit inconvenient, and with the code from warnings_print_categories() as inspiration, I came up with this bit of code (and some boilerplate):

styled_ostream_set_hyperlink (errstream, argc > 1 ? argv[1] : NULL, argc > 2 ? argv[2] : NULL); ostream_printf (errstream, "hello world"); styled_ostream_set_hyperlink (errstream, NULL, NULL); ostream_flush (errstream, FLUSH_THIS_STREAM);

This allows me to test calls into libtextstyle with different hyperlink formats, URLs, etc. In the meantime I built the library with debugging support. Here is a typical crash:

#0 0x0000000000000000 in ?? () #1 0x000000080038230a in delay_output_sp (sp=0x0, ms=<optimized out>) at /usr/src/src/contrib/ncurses/ncurses/tinfo/lib_tputs.c:104 #2 0x0000000800382b81 in delay_output (ms=0) at /usr/src/src/contrib/ncurses/ncurses/tinfo/lib_tputs.c:116 #3 tputs_sp (sp=<optimized out>, sp@entry=0x7fffffffbf88, string=0x800a08083 "", string@entry=0x800a08080 "57b", affcnt=affcnt@entry=1, outc=<optimized out>) at /usr/src/src/contrib/ncurses/ncurses/tinfo/lib_tputs.c:422 #4 0x0000000800382cfb in tputs (string=0x800a08080 "57b", affcnt=1, outc=0x800278c40 <out_char>) at /usr/src/src/contrib/ncurses/ncurses/tinfo/lib_tputs.c:444 #5 0x0000000800278bb0 in out_hyperlink_change (stream=0x800a0d000, new_hyperlink=0x800a790c0, async_safe=false) at term-ostream.oo.c:1586 #6 0x000000080027979c in out_attr_change (stream=0x800a0d000, new_attr=...) at term-ostream.oo.c:1737 #7 0x0000000800278f3b in output_buffer (stream=0x800a0d000, goal_attr=...) at term-ostream.oo.c:1906 #8 0x000000080027647a in term_ostream__flush (stream=0x800a0d000, scope=FLUSH_THIS_STREAM) at term-ostream.oo.c:2052 #9 0x0000000800276f0b in term_ostream_flush (first_arg=0x800a0d000, scope=FLUSH_THIS_STREAM) at term-ostream.c:2729

In this particular case, I have set the ID to “57b”. Why? Well, I originally used the same ID as bison (see the octal dump, above). That crashes, so I had a reproducer but I wanted to cut down the size of what was being printed.

This test-code crashes in konsole. Crashes in alacritty. Does not crash in xterm or urxvt.

In any case, you can see that libtextstyle, in the function out_hyperlink_change(), is calling the ncurses function tputs() with a user-supplied string. The code is here in git as of this writing, but it looks like so:

tputs ("\033]8;id=", 1, out_ch); tputs (new_hyperlink->real_id, 1, out_ch); tputs (";", 1, out_ch); tputs (new_hyperlink->ref, 1, out_ch); tputs ("\033\\", 1, out_ch);

GNU libtextstyle is Free Software, copyrighted by the Free Software Foundation. The code above is licensed under the GPL Version 3.

Here tputs() is being called to send part of an escape code, and then again with the ID (“57b”) and then a semicolon, etc. Actual documentation of tputs() is rather hard to come by, but manpages are fairly consistent in their wording of what parameters there are for the function. Here’s a quote from the OpenBSD manpage for tputs:

The tputs routine applies padding information to the string str and outputs it. The str must be a terminfo string variable or the return value from tparm, tgetstr, or tgoto. affcnt is the number of lines affected, or 1 if not applicable.

The link ID is not a terminfo string variable, nor is it the return value of any of those three functions. Neither is the partial escape sequence, or the single semicolon, or the other two strings. I’m going to conclude that libtextstyle is Doing It Wrong. For nearly all cases, there is no problem with this! What tputs() does is call out_ch() repeatedly, so in the end the string gets written.

Anyway, let’s pipe the output to od -c again to see what’s up:

$ ./example2 2>&1 | od -c 0000000 e x a m p l e . c : 033 ] 8 ; i 0000020 d = b ; h t t p : / / e x a m p 0000040 l e . c o m / 033 \ h e l l o w 0000060 o r l d 033 ] 8 ; ; 033 \

The ID is supposed to be “57b” (see the stacktrace). Where has it gone in output? Only the “b” is left.

A little experimentation shows me that whenever the ID starts with digits, they disappear, and the example program crashes (in konsole, in alacritty, … but not in xterm or urxvt). If it starts with anything else, it’s fine.

At this point I wrote a patch for libtextstyle to write the strings directly, instead of via tputs(). That seemed like the right thing to do, given the wording of the manpage – and it solved my original problem of bison crashing. I’ve got the patch lined up to apply to FreeBSD ports, but I don’t know how to go about submitting it to GNU gettext or GNU libtextstyle.

Fix submitted to the FreeBSD ports tree as PR 260016. I don’t know when (or if) that will land.

libtextstyle bug, squashed

Bug, squashed! But .. why was it crashing in some terminal emulators, why is the ID being mangled?

ncurses code

I wrote another example program. It Does It Wrong, intentionally, by calling tputs() with a user-provided string, like so:

tputs("8675309jenny", 1, out_ch);

On FreeBSD, in all the terminals I tried, this outputs “jenny” without her number. It crashes in the usual suspects. So what’s going on here? The backtrace gives me a line number, let’s take a look at the implementation function, in the FreeBSD git repo. The link goes to the top of the function, but scrolling down a little finds this gem:

#if BSD_TPUTS /* * This ugly kluge deals with the fact that some ancient BSD programs * (like nethack) actually do the likes of tputs("50") to get delays. */

ncurses is Free Software, copyrighted by the Free Software Foundation and Thomas E. Dickey. The code above is licensed under the MIT license.

Well, I am on a BSD, so presumably that define is set, and it does something special with leading digits? Yes indeed: leading digits are consumed and treated as if they were in a $<> block (a not-particularly-well-documented feature where tputs() interprets some parts of the string it is outputting as delay-specifiers, from back when you had a real vt100 on a 2400 bps serial line).

So there we have it: inside the ncurses library, Jenny’s number is consumed and turned into a delay. This is going to call delay_output(), intending to delay for 8675309ms. That’s a little over 140 minutes, enough to let Tommy Tutone play the song thirty times! There’s plenty of decent covers, but it’s still going to get pretty repetetive.

This reinforces my belief that libtextstyle is doing it wrong, in a context where the ncurses library has this kludge.

So we now know why the numbers are being eaten, but not at all why the application then crashes in some terminals and not in others.

Let’s turn back to gdb to step though the code inside ncurses.

(gdb) next 99 NCURSES_SP_OUTC my_outch = GetOutCh(); (gdb) next 102 nullcount = (ms * _nc_baudrate(ospeed)) / (BAUDBYTE * 1000); (gdb) print my_outch $1 = (NCURSES_OUTC_sp) 0x0 (gdb) next 103 for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--) (gdb) print nullcount $2 = 186509

So there’s two things of note here: my_outch is a function pointer for printing delays; something hasn’t been set up properly, or whatever: the function pointer is NULL and we’re going to have a bad time when calling it; we’ll call it 186509 times to output those two hours of delays. (In retrospect, seeing the 0x0 address in the stack trace should have tipped me off much earlier, but I was chasing this bug initially as a konsole issue, so went diving from the top of the applications stack).

Stepping through the same code inside xterm gives me slightly different results:

(gdb) print my_outch $1 = (NCURSES_OUTC_sp) 0x0 (gdb) next 103 for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--) (gdb) print nullcount $2 = -963

Same bad function pointer, but we’ll call it -963 times. That is convenient, since the for loop is never entered and the bad pointer isn’t called. Looking back at the calculation of nullcount here, I checked the value of ospeed when running under konsole: 9600, that’s slow for a terminal but not unreasonable. Under xterm, it says -27136.

Um .. so xterm is avoiding the problem by having an uninitialized (or otherwise garbage) ospeed value, and it’s nothing special about the terminal at all.

Well! Good thing we have the ol’ stty command, which we can use to manipulate speeds. We can use stty speed 9600 for regular-speed terminals, or stty speed 38400 for fast-fast terminals. Heck, I even have a 56k modem, which was fast-fast-fast! That’s bits per second, kids, from back when you could beatbox the sound of a modem syncing and doing carrier detection.

When, in konsole, I run stty speed 9600, and then the sample application, it crashes. Crank up the speed, stty speed 38400 and it’s fine. Checking in xterm, the default speed that xterm has set is 38400. Turning it down a notch: example application crashes. Turning it back to 38400: it’s fine.

Say, -27136, that’s the 16-bit two’s complement value of 38400 (which overflows a 16-bit signed integer). Taking a look at the definition of the ospeed variable, which lives in /usr/local/termcap.h, shows me this:


And yes, on my platform short is probably a 16-bit integer.

Let’s summarize:

  • bison uses libtextstyle,
  • libtextstyle calls some ncurses functions and, it can be argued is Doing It Wrong,
  • but ncurses then uses a NULL function pointer, and that’s not libtextstyle’s fault,
  • except when the terminal baud rate overflows a signed 16 bit integer.
ncurses bug, understood

Bug, understood but not squashed. How are things elsewhere?

Looking at Linux

You know, debuginfo is pretty darn useful, and I’m glad openSUSE’s gdb downloads it automatically. It makes running my example programs much less complicated (I know how to wrangle all the bits on FreeBSD, but not on Linux).

None of the example programs crashed. Running with gdb and setting a breakpoint on delay_output_sp() showed me the following:

  • no_pad_char is set, so the problematic code path isn’t touched at all,
  • ospeed has a value that is not directly the baud rate on the tty (9600 baud yields an ospeed of 13, 38400 baud yields 15, 115200 baud yields 4098).

Looking more closely at the ospeed values, this looks like a mapping of baud rates to internal “enum” values. There are constants defined in termios.h. These have names like B38400, the internal value for 38400 baud. On Linux, the internal value is 017, which (it’s octal!) means fifteen.

There is a function in the ncurses library that maps internal values (e.g. B38400) to actual baud rates (38400 in the case of B38400). On Linux, that maps internal value 15 to 38400. And then in the calculation of how long to delay, it uses 38400 bits-per-second to figure out how many padding characters to send. It doesn’t hit that code path, but it if did, it would be calculating with the right speed.

Back to FreeBSD

On the FreeBSD side, the internal values are the same as the baud rates, e.g. B38400 is defined as 38400 rather than 017. This gives us an interesting tour of ncurses internals and C types, because we have a table of speeds, with entries that get hammered to NCURSES_OSPEED type (short .. signed short).

struct speed { int given_speed; /* values for 'ospeed' */ int actual_speed; /* the actual speed */ }; #define DATA(number) { (NCURSES_OSPEED)B##number, number } static struct speed const speeds[] = { DATA(38400), };

There’s even a comment in the source about older FreeBSD versions that had old-style versions of the defines, and how those do fit into a short. In any case, we end up with initializing an element of the speeds array with B38400, cast to short, then promoted to integer. Because 38400 overflows the short, it’s a negative value, which is promoted to a negative integer: -27136.

When looking up internal values – 15 on Linux, 38400 on FreeBSD – ncurses goes through that table, matching the given speed against the speed value obtained from the terminal (as an internal value, in a short, passed as an int). This happens in the function _nc_baudrate(). So we’re going to be comparing -27136 with values in the table, right? Not so fast: the authors know about overflow, and so there’s specific code in the library:

if (OSpeed < 0) OSpeed = (unsigned short) OSpeed;

So here we take the passed-in value (-27136), mash it to an unsigned short, so in 16 unsigned bits that comes out to 38400, then promote that to int again and assign it back to the variable Ospeed. So we are now looking for a speed value of 38400.

The table contains -27136, and when the comparison is done, it is done with (signed) integers, not shorts, and since those two values differ by 65536 – I am assuming that ints are longer than shorts and more than 16 bits – all the comparisons fail. For any internal value that exceeds 32767, the table-lookup will always fail.

In PR 256731 there is an commit, from an upstream commit, that avoids the NULL-pointer and the crash. Issues with terminal speed remain, so don’t wait around for Jenny.

ncurses bug, mostly-squashed

Bug, mostly-squashed by an update to FreeBSD.

  • Search in the bug database before starting a days-long-debugging-marathon,
  • ncurses and libtextstyle have some neat features that might make sense to use also in other text-based applications of mine.

Catch up: Calamares

Monday 22nd of November 2021 11:00:00 PM

It’s been over a month since I last wrote anything; I acted as a caregiver for my mom for a while, then she moved house which led to frantic painting, unboxing, furniture assembling and all the other time-and-energy sinks associated with moving. Since the end of october I’ve been mostly back at work doing Calamares and KDE and FreeBSD- related things. Let’s catch up on Calamares, first.

  • Calamares 3.2.45 was released at the end of october. This was a first release of Calamares to have some small support for ZFS, thanks to new contributor Evan James. I’m really happy to have new people participating in development – Calamares is there for everyone and should have the things that every (and any) distro needs, either in core or in extensions.
  • Speaking of new contributors, Hacktoberfest was a disappointment in that it yielded nothing-at-all. Not even a nibble. I wrote up some more issues in my Hacktoberfest introductory fashion. That at least is not a total loss, because it involves a bunch of up-front thinking about how an issue could be solved, so later it can be done (e.g. by me or another regular contributor) a little more quickly.
  • Calamares 3.2.46 was released two weeks later. That is the release cadence I try to achieve: push out new things regularly, with whatever is done or new. With a bunch of Arch-derivatives testing the code, and KDE neon unstable doing so too, this shakes things out relatively quickly. This release did some major under-the-hood reworking so that it’s much easier to manage external processes in Calamares; medium term this will shake up a number of the Python modules, too.
  • And right on schedule two weeks later Calamares 3.2.47 was released, now with better privacy controls, and more complete ZFS support.

The ZFS bits are something I’m quite excited about, but they do ask that the distro do some work – the ZFS kernel modules and tools need to be on the ISO, for instance. That doesn’t happen magically, and distro-makers still need to do their thing – and make their own choices; there’s nothing forcing ZFS onto distributions, but Calamares (through Evan) now makes it possible.

Thanks screen from Archcraft Translations

Calamares is available in about 75 languages. 17 of those are at 100% translation, which is a really good statistic. Recent notable work has been to push Sinhala and Farsi (Persian) to 100% translation.

Screenshots with Sinhala and Farsi

Calamares still isn’t great in RTL-mode, but I’ve also never had any reports asking for it (or better yet, pull-requests doing something about it). Those few RTL-writing-people whom I have spoken with about it have told me that crappy layout is so ubiquitous that they would be surprised and concerned if things swapped around in Calamares when switching from RTL to LTR languages.

RTL is “Right to Left”, like Arabic script, which is used for Arabic and Farsi. LTR is “Left to Right”, like Cyrillic script, which is used for Russian and Azerbaijani. To be honest I don’t know which direction to read Sinhala, but I think it’s beautiful.

Distribution Notes

Since Calamares is used by several dozen Linux distributions, it’s convenient to be able to build-and-test on a live ISO. I sat down and wrote out a KDE neon testing and Arch testing guide. That helped me not a few days later when I had full instructions at hand for testing a strange install issue. By writing down the instructions for myself, I didn’t have to think about it much when I needed them.

Similar notes could probably be written for openSUSE, Fedora, and others. The central bit of software is the script which does the heavy lifting; PRs to keep it up-to-date with distro’s are always welcome.

Broader Community and the Future

There are several places where Calamares is developed: the core repository, an extensions repository for more specialized modules and bits, a KDE repository for KDE-specific parts. Some distributions have their own collections of modules. Penguins Eggs is an interesting idea for duplicating Linux installations that also leverages Calamares and has some custom bits.

Distro’s are welcome to add modules to core or extensions. Specialized modules are slowly growing in number, and that’s fine – I’d rather have a good shared central repo of modules with good customizability and configurability than tons of forks.

For the near future, my plans are:

  • get the KDE modules off the ground.
  • reach some level of API stability and branch off a 3.3 LTS version of Calamares.
  • move the development and short-cycle stream of Calamares releases to a 3.4 version. That will give some distro’s a stable thing to work with – useful if they have their own C++-based modules where API / ABI stability has long been an issue in Calamares – and allow us to ditch a whole bunch of backwards-compatbility cruft (e.g. I will no longer be supporting Qt 5.12).

So the future is sunny; kind of like this screenshot from Garuda:

Summary screenshot from Garuda Linux

Cross Compile to PinePhone with Clang

Monday 22nd of November 2021 03:22:07 PM
Cross Compile to PinePhone with Clang Click Here for GCC Part one Click Here for GCC Part three Advantages of Clang If you have read the previous posts about cross-compiling with gcc, you know that we need to install the cross-compiler first. This is not that difficult, but it has a few pitfalls. In particular, the one provided by ArchLinux by default does not work in our use case. The good thing about clang is that clang is inherently a cross-compiler.

Porting Tok To Not Linux: The Journey Of Incessant Failure

Sunday 21st of November 2021 07:32:01 PM

This response from a reader pretty much sums it up:

Stop One: Will Craft Work?

Craft seems like the no-brainer for a KDE project to use, considering it's in-house and supports all of KDE's frameworks and has packaging capabilities. Unfortunately, what sounds good on paper does not translate to what's good in execution.

When I first checked it out, the current version being shipped had incorrect code that would have failed to compile had it been a compiled language instead of Python. Heck, even running a typechecker for Python would have revealed the fact that the code was trying to call a function that didn't exist. Yet, this managed to get shipped. Not a good first impression.

After manually patching in the function into existence on my system, I ran into another hurdle: Craft's env script is broken; mangling PATH to an extent where entries like /usr/bin and /bin and other things got just truncated into oblivion, resulting in a shell where you couldn't do much of anything.

After manually patching PATH to be not mangled, I ran into another and the final hurdle before I gave up: Craft tried to use half bundled libraries and tools and half system libraries and tools, resulting in dynamic linker errors from system tools not finding symbols they needed from bundled libraries.

When I brought these issues up in the Craft chat, the answers basically amounted to a lack of care and “go use Ubuntu.” Not acceptable for Tok considering most of the people interested in building Tok like this don't use Ubuntu, and honestly doesn't make you have much faith in a system for porting utilities to other platforms if said system doesn't even work across the distributions of one platform.

Stop Two: Maybe Conan?

Conan seems like the second-in-line no-brainer for Tok to use. It's the largest C++ package manager, even supporting Qbs. Of course, like with Craft, what sounds good on paper doesn't match up to execution.

Out of the gate, I looked at the Qt package, only to find that there was one (1) Qt package for it consisting of the entirety of Qt, WebEngne and all. Kinda oof, but not a deal breaker. Well, it wouldn't be a dealbreaker if Conan had prebuilt Qt packages for

- Settings: arch=x86_64, build_type=Release, compiler=gcc, compiler.version=11, os=Linux

But it doesn't. I'm not going to build an entire web engine just for an attempt at maybe getting a non-Linux build of Tok, and having to build a web engine as part of Tok's CI is a no-go in terms of disk, memory and CPU.

Stop Three: vcpkg

Considering Microsoft has been a developer tools company for about as thrice as long as I've been alive, I hope their take at the C++ package manager thing is worth their salt.

Some weirdness ensued with the VCPKG_ROOT environment variable at first, but it was easy to fix by pointing it at the vcpkg repo.

While doing the vcpkg install, I found the output somewhat hard to follow, so I had no idea how far along it was. I just let it sit since it seemed to be making progress.

While vcpkg didn't have prebuilt binaries for my setup, it didn't require building all Qt modules like Conan did, so the ask was much more reasonable.

And then I noticed a big issue: vcpkg has absolutely zero versioning, other than the git repository with all the package manifests. This essentially means that in order to build with Qt5, I need to commit to an ancient version of vcpkg packages and stay there indefinitely. I also have to ask users to roll back their vcpkg install that far to build Tok. Not really acceptable as an ask for people who might want to build Tok for not Linux.

Stop Four: Wait, It's Already Here (At Least For Macs)

Turns out Nix, the thing that Tok already supports building with, also supports macOS. Well, that was easy. While it doesn't spit out a premade .app like other porting systems can do, it does ensure a working build with available dependencies, which is already most of the way there.

Conclusion: Apples And Penguins Rule, Everyone Else Drools

Cross-platform C++ packaging and distribution is still a very unsolved problem, unlike other languages/frameworks like Go, Electron, Rust, Zig, etc. as I learned painfully through these escapades. Nix seems the most promising on this front, as it offers a very consistent environment across platforms, which gets you most of the way there in terms of building. It doesn't support Windows (yet?), but simply being able to use a functional compiler instead of Apple Clang is already a killer feature for using it to port apps to macOS.

Qbs is also a huge help in terms of the porting process, as it natively supports building things that require auxiliary scripts or build system hacks with other build systems, like .app bundles, Windows installers, and multi-architecture .app/.aab/.apks with just a few or no extra lines in the build system.

For Tok on macOS, all I need to do is add these two lines to the build script in order to get a usable .app file from it:

Depends { name: "bundle" } bundle.isBundle: true

While it lacks a lot of metadata that you need to fill in yourself, it's again, another 99% of the way there solution where the remaining 1% is mostly just a little data or boilerplate or running a tool.

I still haven't figured out what I'll be doing for Windows, but the need for an end-user Windows package is still a long ways off, considering Tok is still nowhere near a 1.0 release status. Perhaps I can make leverage of Fedora's mingw packages or check out, or maybe just install dependencies from source to a Windows system without a package manager, and bundle them during the build process. If you have any suggestions, do feel free to hop on by in the Tok chat and drop them.

Tags: #libre

This week in KDE: most of GNOME shell in the Overview effect

Saturday 20th of November 2021 04:11:17 AM

This week the new KWin Overview effect gained the ability to shows results from KRunner when you search! This brings it fairly close to feature parity with GNOME’s central Activities Overview feature!

At this rate, we’re about halfway to implementing all of GNOME shell in the Overview effect

Thanks to Vlad Zahorodnii for this work, which lands in Plasma 5.24!

Other new Features

Gwenview now has “Print Preview” functionality, which as I’m sure you can imagine would be quite useful in an image viewer app (Alexander Volkov, Gwenview 22.04)

Discover now prevents you from doing anything that would uninstall Plasma in the process, which is probably not what you were intending to do (Aleix Pol Gonzalez, Plasma 5.24):

Hopefully this is Linus-Sebastian-proof Bugfixes & Performance Improvements

When you print an image in Gwenview or Kolourpaint, it now automatically defaults to printing in portrait or landscape mode according to the image’s aspect ratio, rather than making you set this manually (Alexander Volkov, Gwenview 21.12)

Konsole now releases memory when you clear the text (Martin Tobias Holmedahl Sandsmark, Konsole 22.04)

Konsole now has better text display performance (Waqar Ahmed and Tomaz Canabrava, Konsole 22.04)

The Alacritty terminal once again opens with the correct window size (Vlad Zahorodnii, Plasma 5.23.4)

Toolbar buttons in GTK3 apps that don’t use CSD headerbars (such as Inkscape and FileZilla) no longer have unnecessary borders drawn around them (Yaroslav Sidlovsky, Plasma 5.23.4)

The open/save dialogs in Flatpak or Snap apps now remember their previous size when re-opened (Eugene Popov, Plasma 5.23.4)

The “Show in file manager” text in Plasma Vaults is now able to be translated (Nicolas Fella, Plasma 5.23.4)

The Task Manager’s textual list of grouped apps is now much faster and more performant (Fushan Wen, Plasma 5.24)

Discover now eventually stops searching after no further search results are found, instead of always displaying “Still looking” at the bottom (Aleix Pol Gonzalez, Plasma 5.24)

Fixed an issue with playing certain embedded videos in the Plasma Wayland session (Vlad Zahorodnii, Plasma 5.24)

Fixed a major performance issue in QtQuick-based KWin effects for NVIDIA GPU users (David Edmundson, Plasma 5.24)

The new Overview effect is now much faster to activate (Vlad Zahorodnii, Plasma 5.24)

Tons and tons of small bugs with Breeze icons have been fixed–too many to individually list! (Andreas Kainz, Frameworks 5.89)

Fixed a visual glitch with Plasma tooltips flickering when they appear or disappear (Marco Martin, Frameworks 5.89)

Icons and text in Plasma applet tabs are once again centered as intended (Eugene Popov, Frameworks 5.89)

User Interface Improvements

Elisa’s default album icon is now prettier and more semantically appropriate (Andreas Kainz, Elisa 22.04):

The new Overview effect is now touch-friendly (Arjen Hiemstra, Plasma 5.24)

The touchpad applet has been restored after getting removed in Plasma 5.23, and is now back as a read-only status notifier that simply shows visually when the touchpad is disabled, like the caps lock and microphone notifier applets (me: Nate Graham, Plasma 5.23.4):

The weather applet’s location configuration dialog now automatically searches through all available weather sources rather than making you first select some manually (Bharadwaj Raju, Plasma 5.24):

Discover now presents a more user-friendly set of messages when there is an issue installing updates (me: Nate Graham, Plasma 5.24):

This is a simulated error message, of course.

Web Review, Week 2021-46

Friday 19th of November 2021 12:01:17 PM

Let’s go for my web review for the week 2021-46.

The Inner Osborne Effect

Tags: management, business, product-management

Interesting idea… Until that article, I didn’t fully realize the impact of the Osborne Effect inside of a company and not towards its customers.

Writing great software isn’t all about the software you write – Letters To A New Developer

Tags: tech, craftsmanship, product-management, empathy

Very good advises emphasizing empathy and holistic view of products.

It’s Now Possible To Sign Arbitrary Data With Your SSH Keys

Tags: tech, cryptography, ssh

Little known but potentially very useful SSH feature.

Highlights from Git 2.34 | The GitHub Blog

Tags: tech, git

Lots of good stuff in this release. Particularly looking forward to the new default merge strategy and the ability to sign commits using SSH keys.

String formatting comparison | Pydon’t

Looking for Qt Champions - 2021!

Friday 19th of November 2021 11:23:43 AM

Who do you think should be a Qt Champion? Nominate the champions you know right now!

KDE Floating Panels: ALMOST THERE!

Friday 19th of November 2021 11:11:05 AM

Massimo Stella talks Kdenlive

Thursday 18th of November 2021 11:42:38 AM
Massimo Stella of Kdenlive talks about KDE's 25th Anniversary, how KDE’s video editor came to be, where it is now and what we can look forward to in the future of open source film-making.

I Brought The JingPad To Venice! And The PineBook as well! Oh, right, my girlfriend too

Thursday 18th of November 2021 11:11:43 AM
Stay in the loop: If you want to help me make these videos: Patreon: Youtube: Paypal: My website is and if you want to contact me, my telegram handle is [at] veggero.

KDE Frameworks – Part 2

Thursday 18th of November 2021 10:00:13 AM

CMake is increasingly becoming the de-facto build system for C++ projects. While it has been possible to build Qt applications using CMake for a long time, with Qt6, Qt switched its own internal build system to CMake.

The KDE Community was among the first large, open-source projects that adopted CMake about 15 years ago. Over this time, a lot of experience with CMake has accumulated in the community and solutions for recurring problems have been implemented.

These solutions are available for everyone in the Extra CMake Modules framework, or ECM, for short.

Using Extra CMake Modules

ECM is available from many popular dependency managers, including Conan, Vcpkg, Yocto and, of course, directly from its git repository.

All you need to do to use it in your project is tell CMake to find it and adjust your CMAKE_MODULE_PATH:


Now you are ready to include() its modules. You can find a list of all available modules in the API documentation.

Find Modules

When writing a CMake buildsystem, one often writes custom find modules for integrating third-party dependencies. ECM comes with a number of find modules for various commonly used dependencies, including, for example, GLIB2, Gperf, Inotify, PulseAudio, QtWaylandScanner, wayland-protocols, XCB, TagLib, or EGL.

General Purpose Modules Testing

(Unit)Testing is indispensable for writing and maintaining software. Qt comes with a rich test framework. When using it, you typically create a separate executable for each test. In plain CMake, this comes with some boilerplate:

add_executable(test1) target_sources(test1 PRIVATE test1.cpp) target_link_libraries(test1 Qt::Core Qt::Test myapp) add_executable(test2) target_sources(test2 PRIVATE test2.cpp) target_link_libraries(test2 Qt::Core Qt::Test myapp) add_executable(test3) target_sources(test3 PRIVATE test3.cpp) target_link_libraries(test3 Qt::Core Qt::Test myapp)

ECM provides the ECMAddTests macro, which reduces this boilerplate:

include(ECMAddTests) ecm_add_tests( test1.cpp test2.cpp test3.cpp LINK_LIBRARIES Qt::Core Qt::Test myapp )

An additional benefit of using ECMAddTest is that it enables Q_ASSERT when running the tests; it even does so when built in Release mode, where asserts are usually disabled. This helps your tests find issues in your code without having to build your project in Debug mode.

pkg-config Integration

When developing a library, CMake provides a convenient way for other projects to use your library, in the form of CMake config files. However, you likely also want projects that don’t use CMake to use your library. A popular build-system-agnostic way of exporting libraries is by using pkg-config. Your library would install a mylib.pc file that describes the compiler flags necessary (include paths, libraries, etc.) for using your library. ECM comes with ECMGeneratePkgConfigFile, an easy way to generate the needed .pc file for your project.

add_library(mylib) target_link_libraries(mylib PUBLIC Qt::Core Qt::Widgets) ... include(ECMGeneratePkgConfigFile) ecm_generate_pkgconfig_file(BASE_NAME MyLib INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/MyLib/ DEPS "Qt5Core Qt5Widgets" INSTALL)

This installs MyLib.pc to the appropriate location.


You often want to define your project’s version information in a central place in the build system and propagate the information to the source code, e.g. to make myapp –version work or show it in an “About MyApp” screen. CMake supports passing a VERSION argument to the project() call, which sets up some relevant CMake variables. A common way to pass these variables to the source code is to configure a version header. ECMSetupVersion offers a convenient way to do this:

cmake_minimum_required(VERSION 3.16) project(mylib VERSION 1.2.3) ... include(ECMSetupVersion) ecm_setup_version(PROJECT VERSION_HEADER mylib_version.h) ... install(FILES ${CMAKE_BINARY_DIR}/mylib_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

Now you can access this information from your C++ code:

#include "mylib_version.h" ... qDebug() << "MyLib has version" << mylib_VERSION_STRING; // MyLib has version 1.2.3

This header also provides an expression that is compatible with the QT_VERSION_CHECK macro:

#if mylib_VERSION < QT_VERSION_CHECK(1, 1, 0) myFunction(); #else myOtherFunction(); #endif Qt Modules

Some features in ECM aim at making the interaction with Qt more pleasant.

QMake Integration

Similarly to providing pkg-config files, you may want to deploy the necessary files to use your library from QMake. ECMGeneratePriFile takes care of that for you:

add_library(mylib) target_link_libraries(mylib PUBLIC Qt::Core Qt::Widgets) ... include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME MyLib LIB_NAME MyLib DEPS "Core Widgets" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/MyLib) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) Logging

Qt provides powerful support for categorized logging. However, defining the logging categories comes with some boilerplate. ECMQtDeclareLoggingCategory takes care of some of that boilerplate:

include(ECMQtDeclareLoggingCategory) ... add_executable(myapp) ... ecm_qt_declare_logging_category(myapp HEADER logging.h IDENTIFIER MYAPP CATEGORY_NAME com.mycompany.myapp )

All you need to do is include the generated header and you are good to go:

#include "logging.h" ... qCDebug(MYAPP) << "Hello World!";

Now you can run QT_LOGGING_RULES=”com.mycompany.myapp=true” myapp and enjoy your categorized logging.

It also provides integration with KDebugSettings, a graphical tool for dis/enabling logging categories.

These are only some of the functionalities provided by ECM. Check out the full list of modules!

This post is part of a series of posts about the KDE Frameworks. See Part 1 for an introduction to the KDE Frameworks in general and the KConfig Framework.

About KDAB

If you like this article and want to read similar material, consider subscribing via our RSS feed.

Subscribe to KDAB TV for similar informative short video content.

KDAB provides market leading software consulting and development services and training in Qt, C++ and 3D/OpenGL. Contact us.

The post KDE Frameworks – Part 2 appeared first on KDAB.

More in Tux Machines

ColorTint Adds Translucent Overlay To Help People with Dyslexia, Scopic Sensitivity

For people with dyslexia, scopic sensitivity, and related conditions, GNOME has an extension to adds a a translucent colored overlay over your desktop that may help. It’s ‘ColorTint’ that adds an indicator applet in system tray area. User may click the drop down menu options to enable/disable the overlay, change the color via RGB slider bar, and adjust transparency via the Alpha slider. Read more

Android Leftovers

What Is Linux and Why Is It Important?

Linux is technically not a desktop operating system, but a kernel. The kernel is the part of your computer that enables physical hardware to communicate with what’s on-screen. The kernel is the reason text appears when you type, the cursor moves when you stroke the touchpad, and images appear on your monitor. In the early days of computing, programmers freely shared code and programs. This started to change when corporate entities like IBM, Apple, and Microsoft started to release copyrighted code that users couldn't view and came with restrictions on use. In response, the GNU Project was formed as an effort to create a fully functional computer powered by software that was still freely shared and distributed. Read more

Best Free and Open Source Alternatives to Corel WinZip

Corel Corporation is a Canadian software company specializing in graphics processing. They are best known for developing CorelDRAW, a vector graphics editor. They are also notable for purchasing and developing AfterShot Pro, PaintShop Pro, Painter, Video Studio, MindManager, and WordPerfect. Corel has dabbled with Linux over the years. For example they produced Corel Linux, a Debian-based distribution which bundled Corel WordPerfect Office for Linux. While Corel effectively abandoned its Linux business in 2001 they are not completely Linux-phobic. For example, AfterShot Pro has an up to date Linux version albeit its proprietary software. Read more