PDA

View Full Version : _CrtIsValidHeapPointer Error



navi1084
24th January 2009, 07:47
Hi,
Can anyone tell what is the reason for cause of _CrtIsValidHeapPointer Error???

Thank You

jpn
24th January 2009, 11:11
For example deleting something twice.


int* i = new int;
delete i;
delete i;

Remember that QObjects take ownership of their children. Here's an example how it could happen with QObjects:


{
QObject a;
QObject b;
a.setParent(&b);
}

First "b" goes out of scope and gets destructed according to normal C++ rules. "b" is a parent of "a" so it will automatically delete "a". Then "a" goes out of scope and gets destructed, but it was already deleted by "b" --> crash.