Cleaning non-modal dialog
-
Hi all of you. I am currently working on somebody code. And I encountered a strange problem: when I am trying to clean up the non-modal dialog, I get crashing code. Here is the code:
void CWaitDlg::PostNcDestroy()
{
CDialog::PostNcDestroy();if(m\_bIsDynamicallyAlocated) delete this;
}
when the code arrive to "delete this", is crashing: access violation. Because is NULL. Ok, then I test if is NULL, and if it is, I don't delete it:
void CWaitDlg::PostNcDestroy()
{
CDialog::PostNcDestroy();if(m\_bIsDynamicallyAlocated && NULL != this && NULL != GetSafeHwnd()) delete this;
}
this time it doesn't crash, (the execution doesn't pass by "delete this") but when the project is ending, I get memory leaks, where it created:
CWaitDlg* pWaitDlg = new CWaitDlg;
I have to tell you more: this dialog are used in hidden mode, as an thread. (I repeat, it is not my code). Could you give me an hint how to overcome this ? Thank you.