Inside SWT

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

4 Comments:

  • Wow, porting SWT seems to be dangerous job!

    By Blogger Jörg's noblog, at 10:35 AM  

  • So what was the fix? The bug certainly never mentioned it!

    By Blogger Jim Adams, at 11:14 AM  

  • You're kidding, right?

    First we determined that the message that caused the trouble was TVM_SELECTITEM with the TVGN_CARET flag. Any time we sent it or Vista sent it internally (we had to guess this), the bad thing happened.

    Next, we printed out all the WM_NOTIFY message numbers and noticed some ones we haven't seen before on XP. I guessed that one was a state notification change and returned "one" from the window proc rather than running the default for that message. This stopped all selection changes everywhere (so the guess was right!).

    Finally, we trolled through the MSDN and the new Vista header files and found the real message number (TVN_ITEMCHANGING) and documentation.

    The fix is that when we are changing the selection, we remember the item that should be selected and disallow any other seletion changes.

    The fix only runs on Vista.

    By Blogger Steve, at 1:45 PM  

  • I think I must come from Minguarana sometimes, debugging this Microsoft slop!

    By Blogger Steve, at 9:36 AM  

Post a Comment

<< Home