Archive for January, 2009

Quick tips

January 25th 2009

I’ve rounded up some useful tips, none of which are really important enough to warrant a post just by themselves. So without further ado…

  • If you’re running kdesvn-build, you can use the --refresh-build option to force the given modules to be built with a clean build directory. But what if you didn’t want to do that for all of the modules on the command line? What you can do instead is create a file called .refresh-me in the toplevel of the module’s build directory (e.g. build/kdelibs/.refresh-me). When kdesvn-build rebuilds the module, if it finds that file it will perform the build process as if –refresh-build had been passed. Since –refresh-build involves deleting the build directory this is a one-time-only event. Next time you build everything will work normally.
  • Konqueror deserves several posts on its unique gems just on its own. But one thing I’ll mention is the address bar. There are two different keystrokes that I know of to quickly select the address bar: CtrlAlt - O will select the address in the address bar, handy if you just need to make a quick change to go to a different address. Ctrl - L on the other hand, will delete the text in the address bar first. I think this is a holdover from earlier days to be honest though, as since the URL is selected by default I can’t think of anything that Ctrl - L can do that is easier than using CtrlAlt - O. Update 2:One of the commenters pointed out that the selection buffer gets overwritten using Alt – O but is maintained with Ctrl – L. (i.e., when you middle-mouse-click to paste).
  • Do you use QDataStream? If so then it is imperative that you set the version of the stream. What I mean by this is that sometimes the binary representation changes depending on what version of Qt you are using. So a stream saved by a older version of Qt may be unable to be read using a newer version of Qt with the default version settings. QDataStream is backwards compatible; you just need to know what version to set the stream to. The process is described in the API documentation. Basically you need to set a specific version before writing and before reading. Some types (such as the integer types) are guaranteed not to change their representation, which you can use for versioning.
  • If you are a Qt programmer, then Thiago’s description of QString behavior is required reading.
  • Many people know that the C++ delete operator can safely be called on 0. Per the standard, this is also true for the delete[] operator, so you don’t need to check for null either way. (Of course, there are reports of compilers that screw it up for delete[], sometimes you can’t have your cake and eat it too).
  • And on that note, C++ has an interesting behavior that makes some variadic functions harder to use safely. To wit:
    • C has a NULL macro to represent the null pointer. Typically it would be along the lines of #define NULL ((void*) 0) or thereabouts. void * can be converted to any other pointer type so this is valid.
    • In C++ however, you can’t convert pointer types all willy-nilly. So the #define NULL ((void*) 0) doesn’t work. Instead you use plain 0, which C++ guarantees will be converted to the null pointer when used in a pointer context.
    • The key word here is “used in a pointer context”. Some variadic functions assume that the last parameter will be of a so-called sentinel value. It is up to the programmer to ensure they pass the sentinel correctly, and with the right type. For instance, many gstreamer varargs functions assume a null pointer will be the final argument.
    • If you use the NULL keyword things will work great in C and C++… if you’re on a system where int and pointers have the same size. On 64-bit systems this is not necessarily true.
    • The problem is that NULL is defined to plain 0 for C++. When 0 is passed as the last argument it is assumed to be of int type, not of a pointer type. For most 64-bit systems this will involve placing only 32-bits of 0 on the stack instead of the required 64-bits, and “undefined behavior” results.
    • The solution I used when I encountered this problem in KDE 3′s JuK was to simply define a GST_NULL that did the right thing. Other options are manually casting to a pointer type every time you use one of the vararg functions. But it’s something to keep in mind anytime you’re using variadic functions.
  • The upcoming revision to the C++ standard will include an actual null pointer instead of faking it with 0 and at least this kind of issue can be fixed. Some compilers have already included such a feature (including GCC) and so you may have never encountered this problem.

That’s enough food for thought for now though, hopefully this is enlightening reading for most. Update: The keyboard shortcut is Alt – O, not Ctrl – O.

Posted by mpyne under C++ & KDE & Programming | 8 Comments »

web pages

January 14th 2009

I’ve noticed that many web pages will set a foreground color but assume the background is white. Or (more common) they will set a background color and assume the text is black.

Well, that is horrible for the dark color scheme I use, at least in Konqueror. Remember kids, if you set either of the text or background colors for a web page, you should set them both.

Posted by mpyne under Personal | 3 Comments »

Things

January 14th 2009

So Aaron had a post up about building a community. A couple of the major points he is driving is to make it easy to work on the code, and to make it easy to contribute. In accordance with those principles I have been continuing to work on kdesvn-build as I feel that being able to quickly get into a working KDE development environment can open code review and contribution substantially.

Dominik Haumann also mentioned kdesvn-build and wondered why it is not more prominent in the KDE TechBase build instructions. I’ve not done it because a) I want to avoid “tooting my own horn” so to speak and b) the ever-insidious lack of time. I (obviously) think kdesvn-build is a swell way to setup and maintain your development KDE environment so if people would like I can try and post up instructions on the TechBase.

As far as kdesvn-build goes, I’ve fixed a bug (bug 172719) preventing successful builds of a module if you had more than one option in your cmake-options for that module. In addition I’ve extended support for KDE Subversion module snapshots to modules from extragear and playground, which will help for initial checkout speed.

I’ve changed the handling of the “tag”, “branch”, and “module-base-path” options. They used to automatically add the module name to the end of the generated URL before checking out the module. This was because the way we had Subversion branches and such setup initially always seemed to have an extra module name in the path, at least for most modules. Now that is not the case, so although it is an incompatible change it is time to move on with the times. (I have added a warning for this specific change if kdesvn-build thinks you may be affected by it so you should not be caught unawares I hope). I’ve also been working on finally adding a test suite for kdesvn-build since there are so many features now that I need a way of making sure I don’t break the software by accident from a seemingly minor change.

I haven’t forgotten about JuK either although I’ve not been able to accomplish anything close to what I’d like. For KDE 4.3 the track announcement popup will use XCOMPOSITE extension if available for true transparency. In addition I will at some point make the crossfading optional since it’s kind of a love-it or hate-it thing for many people. I’ve added some more errors checks although I don’t know of any specific bugs that they will fix offhand.

As far as the soon-to-be-released KDE 4.2, I managed to add a new KDE screensaver (the KDE Asciiquarium that I’ve mentioned before). In addition I’ve added a kioslave for Perl documentation and made the man kioslave output more presentable. For KDE 4.3 I would like to condense the stylesheets and such split between the various documentation viewer kioslaves into a common set but we’ll see if I get time. It would make a good junior job I think though if anyone is interested. ;) Also the info kioslave still needs to get transitioned over.

Hopefully that won’t be the extent of my contribution to 4.3 (other than the normal assorted bugfixing) but we’ll see, it just depends on the extra time I get (and that keeps going down as the little one keeps getting older ;).

Posted by mpyne under KDE & Personal & kdesvn-build | 3 Comments »