#define PrimaryContainer std::vector
// ...
for ( PrimaryContainer<ObjectBase*>::iterator iter = ObjStack.begin ( ); iter != ObjStack.end ( ); iter++ ) {
delete (*iter);
}
ObjStack.clear ( );
The above code is causing the following error:
Unhandled exception at 0x00bb374a in A Shapians Tale.exe: 0xC0000005: Access violation reading location 0xfeeefef6.
Which then points to a line in the _Orphan_range method of the vector class (line 1274 in my file, using VC++ 2008). I have no idea what's going on here. I look at the call stack and it shows the clear method being the last function called by myself. The objects derived from the ObjectBase class often have iterators to the ObjStack object. Could the deletion of these iterators be causing problems?
Personally as a first action, I would comment out the delete (*iter);.
If the code runs without crashing, then we can say that the deletion is causing problems.
I would then look at the destructor function of ObjectBase to see what that is doing.