Thanks everyone! :)
I tried taking the class apart, and rebuild it from scratch, using the advice I was given. The class is a wrapper around
Corona that loads the image to pixel data.
Constructors:
CTest::CTest() : data(0){}CTest::CTest(std::string filename) : data(0){ this->Load(filename);}
Destructor:
CTest::~CTest(){ this->Free();}
New Free() method:
void CTest::Free(){ if (!this->valid) return; if (!this->data) return; delete this->data; // this line}
Here is the code in main.cpp that uses the class that crashes:
CTest *Image = new CTest; Image->Load("box.png"); int w = Image->width; int h = Image->height; unsigned char *data= Image->getdata(); delete Image; // this line
I'm now given another error (in a message box, not the normal one):
Debug Assertion Failed!Program: ...File: dbgdel.cppLine: 52Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
Here is the call stack:
msvcr80d.dll!operator delete(void * pUserData=0x02184960) Line 52 + 0x51 bytes C++> TestApp.exe!CTest::Free() Line 51 + 0x18 bytes C++ TestApp.exe!main() Line 61 C++ TestApp.exe!mainCRTStartup() Line 558 + 0x19 bytes C kernel32.dll!RegisterWaitForInputIdle() + 0x49 bytes
Thanks in advance!