The Lessons of a Master

January 24th, 2009  |  Published in Code

Several of us at Camp KDE—myself included—owe a great debt to Till Adam. When he came to the sunny, beautiful beaches of Jamaica, instead of spending his days lounging on the shore or swimming in the warm Caribbean, he chose to pen himself in a stuffy room with a dozen geeks and teach them Qt.

Till works for Klarälvdalens Datakonsult AB (KDAB), the Qt consultancy firm. Besides working on large-scale, enterprise Qt applications, KDAB provides professional Qt training to such companies as IBM, Boeing, Ericsson, and J.D. Edwards. These training sessions usually run a few thousand Euros per person. With the OK from Nokia and Qt Software, Till provided us with a mini two day training course for free!

While the content and materials Till used during the sessions is copyrighted, the information I learned is not. With his permission I’m going to discuss a few pointers in this post. The topics covered somewhat basic/intermediate Qt skills, so those of you who have been programming with Qt for any length of time might not find anything new or interesting. However, for those, like me, who haven’t quite developed our Qt Fu to the Master level, take away tips from here knowing it was passed from a master.

#1 Most Common Performance Issue in Qt
Converting from a QPixmap to QImage too often.

This tip is actually fairly well known, but apparently KDAB consultants run across this mistake very often while in the field. There is a great discussion of this topic over at KDE’s techbase. In summary:

  • A QImage is stored in main memory
  • A QPixmap is stored in video memory
  • Converting from a QPixmap to a QImage is a very expensive operation (see the above article for the explanation)

#1 Most Common Cause of Crashes in Qt
Deleting this from slots

This tip needs some more explanation. Essentially, a mistake many Qt programmers do is include executable code after emitting a signal. Consider this flow of execution:

  • The function Produce::blend() emits signal pineapple()
  • The slot slotBlender() deletes the instance of Produce
  • The signal/slot connection returns to the function Produce::blend(), which has some other executable code such as variable assignments after the emit.
  • Crash. Since the slot deleted Produce, any code following the emit statement that modifies memory is now attempting to write to invalid memory.
  • One good practice to follow is: don’t have any executable code following the last emit statement in your objects’ methods.
    However, the real solution is: Use deleteLater() on your QObjects.

    This post is getting somewhat lengthy and I potentially still have two topics to cover (Threading and Model/View). Most likely I’ll dedicate a post regarding threading in Qt (I took better notes during that talk) in the next couple days. Many thanks to Till for the sessions, as well as KDAB and Qt Software for allowing them to happen.

It’s Jamaica, Mon.

January 19th, 2009  |  Published in Technology

The “conference” ended yesterday as the final presentations were given, however we still have 4 days left here among the sunny beaches. Today Till Adam gave a fantastic lecture-slash-hands-on-workshop of Qt’s Model/View and plugin architecture. Just a couple weeks ago I was slamming my head against the desk trying to wrap my head around Qt’s M/V concepts, the results of which can be seen in Amarok’s new last.fm service browser. Through the creative use of roleplaying (thanks Ade, Jeff, Sebas, and Leo!) and two helpful hands-on exercises I’ve finally gotten a decent grasp of the system. Tomorrow morning we hope to sip QtConcurrent knowledge from the cup that is Till.

I’d write more, but the ocean is calling and I still need to get a Pina Colada. But before I go, check out some photos from the past couple days.

View From Lunch at CampKDE

January 17th, 2009  |  Published in Life

The internet is on the fritz here in Negril, Jamaica at Camp KDE, but while it is working I’ll post this photo taken from the balcony during lunch.

This is also a field test of the WordPress Android application.

We have had 3 presentations so far. Right now Sebastian Kügler is giving a great talk concerning optimizing your applications for mobile devices.

More quality updates soon.


thumbnail

A Quickie: Amarok, Last.fm, CampKDE

January 14th, 2009  |  Published in Uncategorized

Things have been busy around here! First, there was the end-of-semester rush that occurs right before exams, then there was exams themselves. After the 3-day cross country drive home, I’ve spent the last couple weeks playing Settlers of Cataan with old friends, and hitting the ski slopes a couple times a week.

In between all that I haven’t had much time for development. Actually, I told a small lie. I’ve been pretty busy with a secret project ™, but I can’t post anything about that until the 19th.

Amarok wise, things are looking up. I’ve started to completely refactor the last.fm service in Amarok 2. Expect a more explanatory post (plus screenshots!) soon.

Finally, Camp KDE is a few short days away. During the conference Leo Franchi and I plan to knock out some huge improvmeents to Amarok 2′s Context View.

Gah, Gah, Go, that’s all folks!

Im Going to Camp KDE!