#322 CFilterDlg::OnGetdispinfoUserIdList bug

open
nobody
GUI Issue (89)
5
2006-12-12
2006-06-17
denis-0
No

Hello

This following code from the FilterDlg.cpp file
probably has a bug.

void CFilterDlg::OnGetdispinfoUserIdList(NMHDR* pNMHDR,
LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;

LV_ITEM &lv = pDispInfo->item;
if(lv.mask | LVIF_TEXT )
{
lv.pszText = m_arstrUserIds[lv.iItem].GetBuffer(0);
}

*pResult = 0;
}

lv.mask & LVIF_TEXT was probably meant instead of
lv.mask | LVIF_TEXT

Best regards
Denis Linine

Discussion

  • Logged In: YES
    user_id=19748
    Originator: NO

    Could you please describe the user symptom of this problem and where it occurs - also what your code change does/improves? Otherwise I feel like I'm just going to keep glancing over and ignoring it as it involves me doing some work just to find out what the point is ...

     
    • labels: --> GUI Issue
     
  • denis-0
    denis-0
    2006-12-12

    Logged In: YES
    user_id=1541449
    Originator: YES

    Hi,
    The point is that the code is obviously wrong (a typo, most probably). The if(lv.mask | LVIF_TEXT ) statement is always true, no matter what the lv.mask is. This makes the behavior of the list control undefined - instead of setting relevant fields of the passed LV_ITEM to proper values (zeroing them) it always sets its lv.pszText, no matter what kind of information was really requested. In practice: I tried such code in another application and the control worked nearly OK, except sporadically crashing the application because of access violations after returning from the OnGetdispinfoUserIdList call on a Win 9x machine (and not on XP).
    The if(lv.mask | LVIF_TEXT ) statement makes absolutely no sense and I do not think it makes sense to discuss why - it's a typo, most probably, and (lv.mask & LVIF_TEXT ) was meant instead.

    Best regards
    Denis Linine

     
  • Logged In: YES
    user_id=19748
    Originator: NO

    I don't doubt that the code is obviously wrong, etc.
    All I wanted was a small clue as to what control(s) this code affects so that once I've made the change I can go in and sanity check that they still work as intended.
    If I don't get this type information then it means that I have to do the investigation which increases the length of time I have to spend on this bug report, which in turn reduces the chance of me ever getting to it ... thanks.