Let me give you quick scenario:
I have CEdit
decleration in MyDlg.h
but never used.
CEdit m_edit; // member variable of CMyDlg
So, my guess is if I'm not mistaken, any CWnd
controls' m_pWnd
gets destroyed through CWnd::DestroyWindow();
function when application gets closed.
In this case, m_edit
is not getting be created, that means it has no valid m_pWnd
value.
In result, when trying to destroy m_edit
, which m_edit.m_pWnd == NULL
, I think it may be problem.
So, here is my question:
What is the probability of an error occurring in this situation? and how bad is doing this?
Updating question:
When I run my app, sometimes gives this exception: unhandled exception occurred during a user callback
When I see in callStack, called in this order: ~CMainFrame()--> ~CMyDlg() --> ~CEdit() --> ~CWnd()
and it stops in wincore.cpp line804: delete m_pMFCCtrlContainer;
As I explained in old question, I was thinking if it's because of my unused CEdit declaration. But no, even if I commented that out the same issue is happening.
Related to that, there was this answer:
Line 804 in wincore.cpp is only ever hit if m_hWnd != NULL. The statement that m_edit were never used is thus necessarily false. Your code is either constructing a window (through a call to Create or similar), or attaching the m_edit instance to an existing window (commonly done through a DDX_Control in DoDataExchange).
But CEdit variable is not attached to a window (checked in DoDataExchange), also any Create or similar functions are called
So, how do you think what can be the reason of this delete m_pMFCCtrlContainer;
issue??