Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Constructor/Destructor in MFC Extention dll's

Constructor/Destructor in MFC Extention dll's

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiotutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    D D de Kerf
    wrote on last edited by
    #1

    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

    T 1 Reply Last reply
    0
    • D D D de Kerf

      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

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • T Tomasz Sowinski

        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

        D Offline
        D Offline
        D D de Kerf
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups