Feb 06, 2008 15:50
So, another day down the tubes. Be prepared for a code-heavy entry. This is the shit I dealt with today; the GUI for our application wouldn't start, see if you can tell why:
for (int iItemIndex=1; iItemIndex <= int(num_tanks); iItemIndex++)
{
pButtonInfo->strButtonName = QString("Item_Button%1").arg(iItemIndex+1);
if (do_label)
{
QString strLabel = core->getItemInfo(iItemIndex)->Label();
pButtonInfo->strButtonLabel = QString(tr(strLabel));
}
else
pButtonInfo->strButtonLabel = QString(tr("Item %1")).arg(iItemIndex);
pButtonInfo->icon = QIconSet(QPixmap::fromMimeSource("systemitem_small.png"));
buttons.append(pButtonInfo);
}
It's subtle, but it's there. Why the hell is it treating the item index as a value from 0 to N-1 in some places and 1 to N in others? Because it was changed at some point and the person who modified it did not understand what the hell he was doing. So now for item 1 we will use the button name "Item_Button2" and the label for Item 1. It's better than the crash we had before he modified the loop, but it's still screwed up - only in a more subtle way that's still wrong but requires really careful testing to catch.
The damn fool who modified it should have changed the variable while he was at it, so that it would be iItemNumber instead of iItemIndex. But more importantly, it should have BEEN TESTED.
Clearly the code was never run; as soon as it's entered it crashes. WTF.
(never mind that he's looking up a user-entered label in the internal pre-defined language translation table. another WTF.)
wtf,
work,
code