Playing with Qt/KDE

November 3, 2007

justwrite.pngSpeed writing means dumping the contents of your brain as fast as you can without stopping to think or check grammar. The small program I wrote today pretends to help you do it by launching a full-screen window to cover all distractions. It also keeps track of time for you and counts how many lines, words, and letters you’ve written. Here’s the source code (rename to .tar.bz2).

It uses the KDE4 libs, and the preposterous colors are the result of my experimenting with Qt style sheets.

PS. Bonus points if you find a way to crash it! (I know there is at least one)


Happenings

September 15, 2007

Almost a week has passed and I’m still silent. No time? No inspiration? No will?

School is boring like usual. We’re not feeling the full weight of it yet, not until the exams start. Still, spending the first half of the day away from my PC makes me think of how much time I’ve wasted this summer… This year more attention is given to SATs and college applications than to school itself. Teachers had better be understanding or else…

Thankfully, audio-books make the days significantly less monotone.

I’ve been hacking around in KDE, Konsole mostly. So far I helped implement a couple of features which I’m awfully proud of:

  • Double-clicking a tab lets you rename it;
  • Double-clicking the empty space on the tab bar opens a new terminal session;
  • From the menu you can now open Konqueror at the directory you’re currently at.

but I’m still floating around through the files and classes like a clueless wanderer…

So, risking to sound like Abby Normal again, let me just say: ‘later.


A Couple of GDB Tricks

September 2, 2007

What is life without debugging?… :roll:

Getting to know the GNU Debugger can give you lots of power and speed. Unfortunately if you’re working on a big project such as KDE, using it is not always pleasant.

By default, GDB loads the “symbols” from the libraries used by the debugged application. If it wouldn’t do that, it couldn’t tell you the names of classes / functions / variables. When your application uses Qt however, these libraries are huge and can easily eat up 512MB of RAM in debugging symbols. That means that if you don’t have a lot of memory, each time you’ll run your app in the debugger, your machine will start to whirr and thrash. Swap space will be used and performance will go down dramatically.

Fortunately there’s a way around this problem. Robert Knight of Konsole fame shared this on the kde-devel mailing list. The trick is to tell GDB not to load the symbols automatically before telling it to run your application.

set auto-solib-add off

This means that your backtraces will be full of ???s. Notice which libraries your program calls and load them manually with a command like

shar QtGui

This will load all libraries containing QtGui in their names. Don’t try shar Qt as it will load the entire Qt, which we were trying to avoid in the first place.

After loading a library manually, issue the backtrace (bt) command again, notice and load the next library, and so on until you have a full call stack. Now check your memory usage. Relieved? ;)

Many times, however, you may want to attach GDB to an already running process. When you do this (using gdb app-name app-PID), GDB doesn’t give you a chance to stop it from loading the symbols. One way around this is to add the

set auto-solib-add off

line to your ~/.gdbinit file. That means GDB will never load symbols by default. You can return to the old behavior by issuing set auto-solib-add on at any time.


Announcing Konvert2Ogg 0.1

June 17, 2007

Konvert2Ogg is a KDE4 project I have started this month, and today is the big 0.1 day ;) It converts MP3s to Ogg Vorbis, effectively replacing the old command-line tool with a nice GUI.

Here’s the big shiny link:
http://konvert2ogg.sourceforge.net/

I’ve been pleasantly impressed with the service SourceForge offers open source projects for free: hosting, space for downloads, shell access and even svn!


HOWTO: Install Krazy on Ubuntu

June 7, 2007

Here are some quick steps to install Krazy, the KDE static analysis tool (code checker in more accessible language) on your local machine:

  1. sudo aptitude install libtie-ixhash-perl libhtml-parser-perl libfile-find-rule-perl

    These are the Perl dependencies of Krazy. It won’t install without them.

  2. Download the code in a new directory:

    svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdesdk/ebn/krazy/

  3. Change into the directory and start the installation. You may choose the directory Krazy should be installed to, the default is /usr/local/Krazy/. I chose a location in my home directory: ~/krazy/

    cd krazy
    ./install.sh ~/krazy/

  4. To make your environment aware of where the scripts are, adjust your path (in ~/.bashrc):

    PATH=/home/exit/kde4-devel/krazy/bin:$PATH

    Make sure you indicated the right directory.

  5. That’s it! Log-out, log-in to update the PATH and type krazy --list. You should get a list of checks that are available.

Now, to check a single source file, type krazy filename. To check a whole bunch of them, use krazyall. Enjoy 8)


Follow

Get every new post delivered to your Inbox.