GFXDevice::destroy bug
by Gerald Fishel · in Torque Game Engine Advanced · 02/03/2007 (7:44 pm) · 1 replies
Hi,
Not sure if this has been addressed since MS4 since I don't have newer release yet, but just in case, I came across this while looking through the shutdown code in TGEA.
In GFXDevice::destroy there is this block:
Both for loops access smGFXDevice[0]. In the second loop this is probably okay since pop_front is being called each iteration, but in the first loop if arraySize is larger than 1, it's just going to call preDestroy on the first object multiple times. Should probably be: GFXDevice* curr = smGFXDevice[i];
I would think that using the iterators (and maybe combining the loops) and then clearing the vector would be the best way, but that's probably just a style issue. But the first loop definitely wouldn't have the desired effect as it is if there was more than one object.
Best Regards,
Gerald
Not sure if this has been addressed since MS4 since I don't have newer release yet, but just in case, I came across this while looking through the shutdown code in TGEA.
In GFXDevice::destroy there is this block:
// Call preDestroy on them all
for( U32 i = 0; i < arraySize; i++ )
{
GFXDevice *curr = smGFXDevice[0];
curr->preDestroy();
}
// Delete them...all of them
for( U32 i = 0; i < arraySize; i++ )
{
GFXDevice *curr = smGFXDevice[0];
smActiveDeviceIndex = 0;
smGFXDevice.pop_front();
SAFE_DELETE( curr );
}Both for loops access smGFXDevice[0]. In the second loop this is probably okay since pop_front is being called each iteration, but in the first loop if arraySize is larger than 1, it's just going to call preDestroy on the first object multiple times. Should probably be: GFXDevice* curr = smGFXDevice[i];
I would think that using the iterators (and maybe combining the loops) and then clearing the vector would be the best way, but that's probably just a style issue. But the first loop definitely wouldn't have the desired effect as it is if there was more than one object.
Best Regards,
Gerald
Torque Owner Brian Ramage
Black Jacket Games