3
我填充組合框:CComboBox :: GetLBText返回垃圾
while((pHPSet = pHPTable->GetNext()) != NULL)
{
CString str = pHPSet->GetName();
// I am normally using str but to proove that this is
// not the problem I am using "a"
m_comboBaseHP.AddString(_T("a"));
}
現在我想讀的組合框:
if(m_comboBaseHP.GetCount() > 0)
{
CString csHPName = _T("");
m_comboBaseHP.GetLBText(0, csHPName);
// This is the ms way but ReleaseBuffer causes a crash
//CString str = _T("");
//int n = m_comboBaseHP.GetLBTextLen(0);
//m_comboBaseHP.GetLBText(0, str.GetBuffer(n));
//str.ReleaseBuffer();
// Do whatever with csHPName
}
的問題是,csHPName顯示在調試一些中國的跡象。我假設這是內存垃圾。這發生在同一個方法中。這發生在預抽。帖子繪製相同的問題。這發生在調試和發佈。我不明白這是怎麼發生的,因爲我實際上並沒有使用指針。
請任何內存泄漏在你的代碼 – Riskhan
@kTekkie我很欣賞你的意見,但是,這是數百萬行代碼的產品,我相信冥冥中有一些。你能不能更具體地說明爲什麼我要找他們。這是通用的。 – Martin