destructor never called

V

Vince

Hi,

I have a simple Cdialog app with a generic class in it like this :

class CCardObj
{
public:
CCardObj();
virtual ~CCardObj();
BOOL LoadCardMapping();
};
class CBorneDlg : public CDialog
{
public:
CBorneDlg(CWnd* pParent = NULL);
protected:
CCardObj m_Card;
....
DECLARE_MESSAGE_MAP()
}

BOOL CBorneDlg::OnInitDialog()
{
CDialog::OnInitDialog();
BOOL bRet = FALSE;
bRet = m_Card.LoadCardMapping();
if ( ! bRet){
AfxMessageBox("Impossible de lire le mapping de la carte");
this->OnCancel();
return FALSE;
}
For my tests LoadCardMapping always return FALSE so I call OnCanel that kill
the dialog.
But my I trace my app the CCardObj is not detroyed.
Why ?
 
V

Victor Bazarov

Vince said:
I have a simple Cdialog app with a generic class in it like this :

class CCardObj
{
public:
CCardObj();
virtual ~CCardObj();
BOOL LoadCardMapping();
};
class CBorneDlg : public CDialog
{
public:
CBorneDlg(CWnd* pParent = NULL);
protected:
CCardObj m_Card;
...
DECLARE_MESSAGE_MAP()
}

BOOL CBorneDlg::OnInitDialog()
{
CDialog::OnInitDialog();
BOOL bRet = FALSE;
bRet = m_Card.LoadCardMapping();
if ( ! bRet){
AfxMessageBox("Impossible de lire le mapping de la carte");
this->OnCancel();
return FALSE;
}
For my tests LoadCardMapping always return FALSE so I call OnCanel that
kill
the dialog.
But my I trace my app the CCardObj is not detroyed.
Why ?

It's impossible to say without knowing what you mean by "kill the
dialog". Does the destructor for CBorneDlg get called? If not,
how would your 'm_Card' be destroyed?

V
 
V

Vince

Vince a écrit :
Hi,

I have a simple Cdialog app with a generic class in it like this :

class CCardObj
{
public:
CCardObj();
virtual ~CCardObj();
BOOL LoadCardMapping();
};
class CBorneDlg : public CDialog
{
public:
CBorneDlg(CWnd* pParent = NULL);
protected:
CCardObj m_Card;
...
DECLARE_MESSAGE_MAP()
}

BOOL CBorneDlg::OnInitDialog()
{
CDialog::OnInitDialog();
BOOL bRet = FALSE;
bRet = m_Card.LoadCardMapping();
if ( ! bRet){
AfxMessageBox("Impossible de lire le mapping de la carte");
this->OnCancel();
return FALSE;
}
For my tests LoadCardMapping always return FALSE so I call OnCanel that kill
the dialog.
But my I trace my app the CCardObj is not detroyed.
Why ?
Actually it is called but I didn't notice
 
R

Ron Natalie

Vince said:
For my tests LoadCardMapping always return FALSE so I call OnCanel that kill
the dialog.
But my I trace my app the CCardObj is not detroyed.
Why ?

Most likely because the CborneDlg is never desroyed.
The stupidity of MFC is off-topic for this group, but let
me impart one piece of wisdom: Making the dialog go away
(destroying it's window) and destroying the CDialog that
goes with it are two distinct items. I suspect you're
not doing the latter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,310
Members
47,977
Latest member
MillaDowdy

Latest Threads

Top