Vector of SimObjectPtr corrupts memory
by William Todd Scott · in Torque Game Engine Advanced · 08/12/2007 (12:04 pm) · 3 replies
Hi,
I have a class with a data member that is a vector of SimObjectPtrs to datablocks as such:
Vector> mDatablockList;
However, when this class is deleted memory gets corrupted.
I was wondering if anyone knows why this might be the case?
At first I thought it was because the destructor for tVector calls free() without calling the underlying destructors for its objects. However, I tried emptying the list before the tVector destructor is called and I still get the corruption.
Thanks
Todd
I have a class with a data member that is a vector of SimObjectPtrs to datablocks as such:
Vector
However, when this class is deleted memory gets corrupted.
I was wondering if anyone knows why this might be the case?
At first I thought it was because the destructor for tVector calls free() without calling the underlying destructors for its objects. However, I tried emptying the list before the tVector destructor is called and I still get the corruption.
Thanks
Todd
#2
Thanks for the response.
Right now I am just using VectorPtr, which works, but unfortunately loses the benefits of the SimObjectPtr.
I don't quite get why Vector's use of constructInPlace and destructInPlace would be problematic with the SimObjectPtr, since it is an object and it has a default constructor defined.
Thanks
Todd
08/12/2007 (8:52 pm)
Hey Pat,Thanks for the response.
Right now I am just using VectorPtr
I don't quite get why Vector's use of constructInPlace and destructInPlace would be problematic with the SimObjectPtr, since it is an object and it has a default constructor defined.
Thanks
Todd
#3
08/13/2007 (11:35 am)
Vector should be working, is the thing. I am not sure why it isn't. At first I thought this was the standard Vector/VectorPtr confusion. I checked to see if I was using a vector of SimObjectPtrs anywhere, but the closest I have is a Vector of a struct with a SimObjectPtr inside.
Torque 3D Owner Pat Wilson