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. I need help with an arrogant CFile

I need help with an arrogant CFile

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelpquestionlearning
4 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I have a CFile member variable who seems angry with me because doesn't do what I want. Here's the code in MyClass.h: public: CFile* myFile; in MyClass.cpp: CMyClass::CMyClass() { myFile = new CFile; } CMyClass::~CMyClass() { delete myFile; } //My class is derived from CPropertyPage BOOL CMyClass::OnInitDialog() { if (myFile->Open("some.file", CFile::modeRead)) { //Dosomecode myFile->Close(); } } And I get: Debug Assertion Failed! // More things Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) // More things Since I'm learning C++ and I don't understand what is happening, I need somebody to help me and show that stupid file who is the programmer and not to crash again. Thanks in advance,

    J T 2 Replies Last reply
    0
    • L Lost User

      I have a CFile member variable who seems angry with me because doesn't do what I want. Here's the code in MyClass.h: public: CFile* myFile; in MyClass.cpp: CMyClass::CMyClass() { myFile = new CFile; } CMyClass::~CMyClass() { delete myFile; } //My class is derived from CPropertyPage BOOL CMyClass::OnInitDialog() { if (myFile->Open("some.file", CFile::modeRead)) { //Dosomecode myFile->Close(); } } And I get: Debug Assertion Failed! // More things Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) // More things Since I'm learning C++ and I don't understand what is happening, I need somebody to help me and show that stupid file who is the programmer and not to crash again. Thanks in advance,

      J Offline
      J Offline
      James Pullicino
      wrote on last edited by
      #2

      The assertion happens when you delete right? (2b || !2b)

      L 1 Reply Last reply
      0
      • J James Pullicino

        The assertion happens when you delete right? (2b || !2b)

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Yes, I think so. The application opens a property page and it crashes when I close it, but if I debug it it goes to HandleMap::DeleteTemp or something like that.

        1 Reply Last reply
        0
        • L Lost User

          I have a CFile member variable who seems angry with me because doesn't do what I want. Here's the code in MyClass.h: public: CFile* myFile; in MyClass.cpp: CMyClass::CMyClass() { myFile = new CFile; } CMyClass::~CMyClass() { delete myFile; } //My class is derived from CPropertyPage BOOL CMyClass::OnInitDialog() { if (myFile->Open("some.file", CFile::modeRead)) { //Dosomecode myFile->Close(); } } And I get: Debug Assertion Failed! // More things Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) // More things Since I'm learning C++ and I don't understand what is happening, I need somebody to help me and show that stupid file who is the programmer and not to crash again. Thanks in advance,

          T Offline
          T Offline
          tanin
          wrote on last edited by
          #4

          I think you should delete the file pointer not in the window destructor but add an event OnClose and then delete the pointer there, if it doesn't help than u can send me your project to pudaoman@hotmail.com and i'll try to hel you. :rolleyes:

          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