snakefoot/cgridlistctrlex

Crash on destroy window

yscgz opened this issue · 3 comments

yscgz commented

After I changed text of ComboEdit control by using SetCurSel(), then exit application by clicking x, application crashed. I tracked on CGridEditorComboBox::EndEdit(), and m_Completed is false, but at that time, its parent window had been destroyed. I found it just set m_pComboBox as NULL in CGridColumnTraitCombo::OnEditEnd(), not using delete. Is there any risk of memory leak?

yscgz commented

Here is my fixed-bug code:

void CGridColumnTraitCombo::OnEditEnd()
{
    if (m_pComboBox)
    {
        delete m_pComboBox;
    }
    m_pComboBox = NULL;     // CGridEditorComboBoxEdit automatically deletes itself
}

Have you read the comment for the NULL assignment? CGridEditorComboBox::EndEdit() calls PostMessage(WM_CLOSE) and CGridEditorComboBox::PostNcDestroy() performs the delete.

Instead of investigating leaks when the application crashes, then I would rather investigate the reason for crash. If you have found a scenario where CGridListCtrlEx is causing a crash, then please tell.

yscgz commented

Yes, you're right. I should use SetItemText() to change the text of combobox, not use OnEditBegin() to get the pointer, then use SetCurSel().