Inside SWT

Monday, September 25, 2006

How many times have you done this?

You've got a problem to solve. It's really complicated. Rather than attempt the final solution, you hack and slash a way through it. The code you wrote is not real. It is total garbage. It proves that the problem can be solved, but you could never ship like that.

What now? Time to step back, write the general solution, rework everything, fix the corner cases, check for error conditions, change all places that do it the old way to do it the new way, check for leaks and clean up the code. Now you are done and ... nothing works.

By this time, you've blown away the old code so you have no idea what the problem is. Did it ever work at all? What did I change? Was I doing a Billy?

Steve

Monday, September 18, 2006

Alphabet soup

The other day I had to make a presentation and started listing the various different technologies that we support. Here are some of them:

Win32, GDI, GDI+, OLE, IE, Carbon, Cocoa, Core Graphics, Quick Draw, Safari, ATSUI, X Windows, X/t, Motif, GTK, GDK, Pango, cairo, ATK, Photon, Mozilla, QNX Voyager, Uniscribe and I almost forgot AWT/Swing.

What's the message? Forget about technology wars. Go forth and build something!

Steve

Monday, September 11, 2006

ayahuasca

Have you heard of this stuff? It's a brew made out of vines and leaves from the Amazon rain forest. It causes blinding, vivid, hyper-real hallucinations. It's so strong that people who take it sometimes wear Depends because they shit themselves and/or vomit uncontrollably. Mmmm ... gimme some of that!

What does this have to do with software? I was wondering whether ayahuasca might help me debug a problem I was having with SWT on Vista. As you may not know, multi-select trees are not supported natively on Windows. We emulate them using the wad of code pattern on top of the native tree. It seems that Microsoft finally got around to trying to implement multi-selection, but bailed at the last minute (see TVS_EX_MULTISELECT). My guess is that some of that code still remains in Vista.

Anyway, the bug was that when you selected the nth item, the n-2th selected item was deselected for free (NOTE: not the n-1th). Ok, I'm easy. I went and happily remembered the n-2th item and reselected it. Then, Vista started deselecting the n-3rd item. The chase was on! No matter how many I remembered and reselected, Vista deselected one more. Then I took the ayahuasca.

The fix came in a blinding flash!

Steve