Constructor/Destructor in MFC Extention dll's
-
OK, so I made myself an MFC Extention dll (this time I used MFC as shared library and all, everything looks ok), but I've still got some problems here... I want to export a couple of classes from my extention DLL and things go wrong in de destructors.... For example, I tried the following code: // --- This one goes OK --- // CMyObject has a couple of members: strings, pointers and numbers CMyObject * pNew = new CMyObject(); delete pNew; // --- This one stinks ---- // CMyComplexObject has a couple of protected members, which are pointers to CMyObject instances // CMyComplexObject creates the instances of the members in the constructor with 'new' and deletes them in // the destructor with 'delete'. CMyComplexObject * pNew = new CMyComplexObject(); // This goes correctly delete pNew; // Application crashes on the delete of it's own members (the ones it made with 'new' in the constructor)! :confused: :confused: :confused: Structured programming vs. chaotic mind boggling
-
OK, so I made myself an MFC Extention dll (this time I used MFC as shared library and all, everything looks ok), but I've still got some problems here... I want to export a couple of classes from my extention DLL and things go wrong in de destructors.... For example, I tried the following code: // --- This one goes OK --- // CMyObject has a couple of members: strings, pointers and numbers CMyObject * pNew = new CMyObject(); delete pNew; // --- This one stinks ---- // CMyComplexObject has a couple of protected members, which are pointers to CMyObject instances // CMyComplexObject creates the instances of the members in the constructor with 'new' and deletes them in // the destructor with 'delete'. CMyComplexObject * pNew = new CMyComplexObject(); // This goes correctly delete pNew; // Application crashes on the delete of it's own members (the ones it made with 'new' in the constructor)! :confused: :confused: :confused: Structured programming vs. chaotic mind boggling
What exactly the crash looks like? Are you getting an ASSERT? This again looks like two different heaps in your program. Tomasz Sowinski -- http://www.shooltz.com.pl
-
What exactly the crash looks like? Are you getting an ASSERT? This again looks like two different heaps in your program. Tomasz Sowinski -- http://www.shooltz.com.pl
And you're right... I finally got the whole smash to work by creating a clean extention dll-project and more or less copying the project settings from one to the other... There was another problem that caused the crash, though. I used two seperate .h files for my objects, one for usage in the client and one for the dll itsself. The class I was talking about had a slight difference in both .h-files, which probably caused the whole allocation/deallocation mechanism to mess up.... Anyway, I was able to fix it, thanks to your help! Thanks a lot ('cause I've been quite a pain-in-the-thingy). I've learned a thing or two, again! :) Structured programming vs. chaotic mind boggling