Tag Archives: Rant

The QThread anti-pattern

Sometimes with QThread you see something like this:

void run()
    while (true) {
            QMutexLocker lock(&mMutexData);
            if (mQuit)
        msleep (200);
void stop()
    mQuit = true;

This is potentially problematic. Why? Consider the extreme case of a function shutdown() which does something like this:

void shutdown()
    delete thread;

Congratulations, you’ve just introduced a race condition. Why, you will ask? You’re waiting for the thread to end before deleting it, right?

No. And this has to do with the way Qt implements QThread::wait() which you should have probably used in the first place, if you really need this sort of functionality.

Qt hooks a pthread cleanup handler in the native thread which will call wakeAll() on a QWaitCondition stored inside the pimpl of QThread. And this pimpl – you might have guessed – is gone when you call delete.

Trekstor Vibez and Jaunty^WLucid

So – A year has passed, two Ubuntu versions, what’s the state of MTP vs. mass storage? Apparently still broken. Same same but different.

Instead of making the player crash, gphoto2/libmtp and usb mass storage fight for the right to access the device which leads to very ugly errors in dmesg that look like the device or at least its file-system is severely broken ­čÖü

So, once again: Either make the device MTP only or remove the device’s entry from the libmtp udev rules which now reside in /lib/udev/rules.d/45-libmtp8.rules

Kolmas viikola Helsingiss├Ą

or: You’re holding it wrong. Seriously. Once upon a time, you could buy a IBM/Lenovo ThinkPad with Intel graphics and it just worked. While the Intel issues in the last versions of Ubuntu were mostly home-grown, the current disaster with the Core i3/i5 on-chip graphics isn’t. Like in the X201.

The Ubutu experience

Getting Ubuntu 10.4 LTS to work on an X201 isn’t too hard. You just need to follow some simple steps:

  1. Get Ubuntu (obviously) and put it on an USB stick; the X201 doesn’t have a CD drive
  2. Go to http://people.canonical.com/~hzhang/554569/ and grab the latest kernel package linked there (see also Launchpad bug 554569)
  3. Get the most recent BIOS update from Lenovo. A description on how to update your BIOS if you don’t have an optical drive may be found at thinkwiki.org
  4. Go to the BIOS setup and deactivate Intel AMT.
  5. Install Ubuntu normally. The installer should work just fine. If the graphical installer doesn’t, try the alternate install CD.
  6. After the installation is done, boot from USB once again and go into rescue mode to install the kernel package downloaded before.
  7. Boot normally.

Remaining issues

  • External video
    VGA works, but if you shut down the machine with the external monitor connected, it will somehow lockup (CPU is busy)
  • Suspend/Resume
    With the kernel from the launchpad bug, USB works after resume; the only thing I noticed is that sometimes the wireless LAN won’t come up again (like 1 in 10 resumes).
  • UltraBase
    No idea yet. Haven’t used though it is said that there are still problems with the display port on it

A plea agains tofu

No, not the stuff made from soy beans. Tofu is the the german term for a behaviour most likely found in corporate email. It means “Quote full, add your text on the top”. That’s sort of reversed “AOL” behaviour.

When I started email, I came from a FIDO background (anyone remembers this? BBS and stuff?). Connection time was precious and expensive. Quoting rules existed like don’t quote too many levels, answer inline etc. When moving on to the internet, I mostly kept this.

I dropped writing emails like this like five years ago, when I entered the magical world of business emails. Noone understood inline replys and most people were complaining that the communication history was missing. So I adapted, at least at work. And Outlook 2007 even has support for navigating in mails like those. I also understand why a certain kind of people like it. When you print the mail, you only need to print one mail and have the whole conversation at hand.

But honestly. I’m doing a lot of mail on my mobile phone currently. Fetching mails is not too fast on there. I don’t want to download 200k for a simple “Me too”. I don’t want to scroll through all of the shit. I don’t event want to download the same shit again and again. I already have the communication history available.

Herr, schmei├č Hirn vom Himmel…

Liebe CDU,

in Zeiten, in denen Ihr unsere Grundrechte gerne mal mit F├╝├čen tretet und euer Innenminister wahrscheinlich am liebsten Kameras in jedem Privathaushalt installieren w├╝rde, sorgt IHR EUCH UM EURE Sicherheit und Privatsph├Ąre? Ihr seid peinlich, ernsthaft…

Mir ist schleierhaft, warum euch eigentlich immer noch Leute freiwillig w├Ąhlen.

Mit nicht ganz so freundlichen Gr├╝├čen

Eternal struggle

My current task is evaluation crypto (here: OpenPGP) solutions for Microsoft Windows; of course including GnuPG.

Well, what do I say. While there is a nice installer for GnuPG on Windows available (either here or here), try to find one for the gpgme supporting library… (including header and .lib import files for Visual Studio, that is).

You can guess… It’s all about build-your-own-stuff. It basically boils down to this:


  • Create a directory to collect all the stuff you will need (e.g. C:\gpgme with bin, include and lib sub folders)
  • Get mingw and install it
  • Get MSYS and install it
  • Download libgpg-error and extract it
  • Download gpgme and extract it

Compiling libgpg-error

  • In the MSYS bash, change to the directory you extracted libgpg-error into and run ./configure --prefix=/mingw && make install
  • Call strip src/.libs/libgpg-error-0.dll src/gpg-error.exe as MSVC can’t use gcc’s debug info anyway
  • Copy src/gpg-error.exe and src/.libs/libgpg-error-0.dll to the bin directory created above
  • Copy src/.libs/libgpg-error-0.dll.def to lib/libgpg-error-0.def (note the renaming; otherwise your program will look for a libgpg-error-0.dll.dll)
  • Open the Visual Studio Command Prompt
  • Call lib /machine:i386 /def:lib\libgpg-error-0.def /out:lib\libgpg-error-0.lib to create the import library
  • Copy include/gpg-error.h to include

Compiling gpgme

  • In the MSYS bash, run ./configure --prefix=/mingw && make
  • Call strip src/gpgme-w32spawn.exe src/.libs/libgpgme-11.dll
  • Copy src/gpgme-w32spawn.exe to bin Note: To use the gpgme library, this binary has to live either in the installation dir of gpg (set in windows registry key HKLM\Software\GNU\GnuPG\Installation Directory) or in %PROGRAMFILES%\GNU\GnuPG. Otherwise gpgme will not work!
  • Copy src/.libs/libgpgme-11.dll to bin and src/.libs/libgpgme-11.dll.def to lib/libgpgme-11.def (Once again, note the renaming)
  • Call lib /machine:i386 /def:lib\libgpgme-11.def /out:lib\libgpgme-11.lib to create the import library
  • Copy include/gpgme.h to include

Optional: Creating the documentation

I was not able to create the documentation properly using cygwin so I did this on a Linux host. Install a TeX distribution of your choice as well as texinfo (for Debian Lenny this would mean installing the packages texinfo, texi2html and texlive). Call make pdf in the doc subdir to generate the PDF documentation and manually call texi2html gpgme.texi for a HTML document.


Now you can add the lib dir to your Visual Studio linker settings and the include dir to your C/C++ common settings. To make gpgme work, be sure you have the gpgme-w32spawn.exe installed properly as noted above.

I hope this helps to guide one or another through the struggle of getting gpgme on windows.


  • Q: gpgme does not find libgpg-error

    A: You did not call make install after compiling it

  • Q: My program is looking for {libgpg-error-0.dll.dll|libgpgme-11.dll.dll}

    A: You did not rename the .def file before calling lib.exe

  • Q: I did everything you said, but when I run my program, gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) fails with GPG_ERR_INV_ENGINE. If I check the engine info, info->version is empty

    A: First of all, check if you copied gpgme-w32spawn.exe to the correct directory. If this is the case, actually, I have no idea what went wrong