Bug reports – sometimes it’s easier to fix than just report

The problem uncovered in the last post – that a popup didn’t pop up on my computer – turned out to be due to a race condition. Basically, two relevant things happen when a Qt widget (in this case, a combo box) is clicked:

  • A “Signal” is emitted with the new setting
  • The widget is set as active, if it’s not already active

The bug came about because there was a check to make sure the widget was active before triggering the popup (which is only mean to pop up on the first time a setting is changed). On my computer, the signal is emitted first, which triggers the check before the widget becomes active: no popup. Apparently on other peoples’ computers, the widget gets set active, then the signal is emitted and the check passes: popup.

The key clue for me was that I noticed I could make the popup appear by triggering the setting change via keyboard. Looking at the code and adding some debugging output confirmed the problem, and it was less work to submit a possibly-fixed version of the code than writing this post to explain the problem!

I should emphasise the “possibly” – there’s probably a good reason for that check, and my “fix” was just to remove the check. By removing the check the problem went away, so I knew I had found the source of the bug.

But, that’s a lot of what programming is about – subtle details.

Cost: 1 1/2 cups of tea, counting this post

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s