473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

destructor never called

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 ?

Jul 22 '05 #1
3 1718
"Vince" <bi********@yahoo.fr> wrote...
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
Jul 22 '05 #2
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
Jul 22 '05 #3
Vince wrote:
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.
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

52
by: Newsnet Customer | last post by:
Hi, Statement 1: "A dynamically created local object will call it's destructor method when it goes out of scope when a procedure returms" Agree. Statement 2: "A dynamically created object...
9
by: sahukar praveen | last post by:
Hello, This is the program that I am trying. The program executes but does not give me a desired output. ********************************************** #include <iostream.h> #include...
11
by: Stub | last post by:
Please answer my questions below - thanks! 1. Why "Derived constructor" is called but "Derived destructor" not in Case 1 since object B is new'ed from Derived class? 2. Why "Derived destructor"...
16
by: Timothy Madden | last post by:
Hy I have destructors that do some functional work in the program flow. The problem is destructors should only be used for clean-up, because exceptions might rise at any time, and destructors...
6
by: Squeamz | last post by:
Hello, Say I create a class ("Child") that inherits from another class ("Parent"). Parent's destructor is not virtual. Is there a way I can prevent Parent's destructor from being called when a...
11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
4
by: Joe | last post by:
I am looking for the quintessential blueprint for how a C++ like destructor should be implemented in C#. I see all kinds of articles in print and on the web, but I see lots of discrepencies. For...
35
by: Peter Oliphant | last post by:
I'm programming in VS C++.NET 2005 using cli:/pure syntax. In my code I have a class derived from Form that creates an instance of one of my custom classes via gcnew and stores the pointer in a...
14
by: gurry | last post by:
Suppose there's a class A. There's another class called B which looks like this: class B { private: A a; public : B() { a.~A() } }
5
by: junw2000 | last post by:
I use the code below to study delete and destructor. #include <iostream> using namespace std; struct A { virtual ~A() { cout << "~A()" << endl; }; //LINE1 void operator delete(void* p) {...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.