1.0 crash-on-exit due to GFX being NULL during GFXPCD3D9TextureTarget::zombify().
by Orion Elenzil · in Torque 3D Professional · 10/29/2009 (8:19 pm) · 0 replies
howdy folks -
just checking in to see if this is a known issue.
during shutdown, GFXPCD3D9TextureTarget::zombify() gets called,
which steps through each "RenderSlot" (not sure what those are),
and calls attachTexture(NULL) on each one.
attachTexture() then uses the GFX macro (which just returns smGFXDevice)
(aside: GG, i'm curious, why do this:
----------
public:
static GFXDevice* get() { return smGFXDevice; }
----------
and then wrap that in a macro instead of the seemingly simpler (and easier to debug):
----------
public:
static const smGFXDevice;
----------
and forget the macro and the getter() and just access GFXDevice::smGFXDevice ?)
.. and at this point smGFXDevice is NULL, and so the following line naturally crashes:
static_cast<GFXD3D9Device *>( GFX )->destroyD3DResource( mTargets[slot] );
this is easily fixed by modifying the code to look like this:
but it makes me nervous that this obviously frequent use-case is having problems for us.
ie, we may have busted something.
any popular wisdom on this one ?
tia,
orion
just checking in to see if this is a known issue.
during shutdown, GFXPCD3D9TextureTarget::zombify() gets called,
which steps through each "RenderSlot" (not sure what those are),
and calls attachTexture(NULL) on each one.
attachTexture() then uses the GFX macro (which just returns smGFXDevice)
(aside: GG, i'm curious, why do this:
----------
public:
static GFXDevice* get() { return smGFXDevice; }
----------
and then wrap that in a macro instead of the seemingly simpler (and easier to debug):
----------
public:
static const smGFXDevice;
----------
and forget the macro and the getter() and just access GFXDevice::smGFXDevice ?)
.. and at this point smGFXDevice is NULL, and so the following line naturally crashes:
static_cast<GFXD3D9Device *>( GFX )->destroyD3DResource( mTargets[slot] );
this is easily fixed by modifying the code to look like this:
GFXD3D9Device * dev = static_cast<GFXD3D9Device *>( GFX );
if (dev == NULL)
{
// oxe - we were crashing-on-exit because GFX was returning null.
Con::errorf("%s() - GFX unexpectedly NULL. not calling destroyD3DResource().", __FUNCTION__);
}
else
{
dev->destroyD3DResource( mTargets[slot] );
}but it makes me nervous that this obviously frequent use-case is having problems for us.
ie, we may have busted something.
any popular wisdom on this one ?
tia,
orion
About the author