Postings tagged with Programming
Using DBus as lock-daemon
Recently I found this comment in the source code I am working with:
// what if both processes read in the same time and write at the same time, no increment
Please! Don't do such things! Don't just leave such comments in hope someone else will come around and will fix later. Please take the time to apply a locking mechanism.
Obvious choice when dealing with files would be to create a lock file. Unfortunately creating a ...
GCC 4.5 - Awesome Release!
GCC 4.5 just was has been released yesterday. It's a really awesome release according to its summary of changes. My favorites:
- The -Wc++-compat option is significantly improved.
- Compilation time for code that uses templates should now scale linearly with the number of instantiations rather than quadratically, as template instantiations are now looked up using hash tables.
- Improved ...
About reinventing the wheel
Nice article: I Can't Wait for NoSQL to Die. Fits on many IT problems, not only SQL vs. NoSQL. Should be common knowledge, but apparently is not.
Bottom line: First of all do some research before throwing out the baby with the bath. And no: Jumping on the current hype won't magically cure your self made skill/knowledge/management/whatever problems.
Fragile API and invalid iterators
For the Miniature project I sometimes need to iterate over all graphics items in a QGraphicsScene, or more precisely, all items of a specific parent item, the chess board itself. For that, I use the QGraphicsItem::childItems() API. However, when used with STL-style iterators you have to be careful, since value types of that form can easily break the iterator idiom:
for (QList<QGraphicsItem *>::iterator iter = parent_item->childItems().begin();
iter != parent_item->childItems().end();
++iter)
{
...
About delegates and cell renderers - data formatting in Qt
Warning: the following blog post has a rant-to-usefulness ratio of 3:1.
Last week I needed to perform some data formatting on Qt list view. From reading the documentation alone I could not find a satisfying answer. When asking on IRC the answer was to use proxy models. This would have worked, but having two models for one view can create all kind of correspondence problems (think of sorting etc.). And there is [this ...
Miniature - it moves!
How it begun
When I read Quim's thread about the idea for a better Maemo chess app I knew I wanted to join the project. To me, it's all about the device and the sparkling Hildon UX. I really want a good chess app, for myself! I want to play chess online, everywhere! And I want to analyze ...
Wt - a Qt-ish web toolkit written in C++
First of all, C++ for web apps doesn't necessarily make it easier to write them. Compared to other solutions (let's say Django) you'll end up writing a lot more code. And you have to be very very careful with memory leaks.
But that isn't the point. The main advantage of this framework is how close it is to desktop applications. Porting your Qt desktop application to the web is certainly easier with Wt than with any other solution, as you keep most of the widget API and also the signal and slots paradigm (which should allow to port the ...
C++ Template Poisoning
Today I was sick. At first I thought, "Ha, serves you right for eating dead animals!", but then I realized this weren't the usual kind of stomach problems. All of a sudden it struck me - I had a C++ Template Poisoning!
So what happened? I've been busy picking up C++ over the last weeks, mostly from reading books. When I ...
C genuinely less powerful than modern languages
So today I finally realized that C is not only less convenient than modern programming languages, it's also genuinely less powerful than modern languages: In garbage collected (and reference counted) languages you can easily write:
if (attr_list != priv->cached_attr_list ||
0 != list_compare (attr_list, priv->cached_attr_list)) {
priv->attr_value = parse_attr (attr_list);
priv->cached_attr_list ...