1
0
Fork 0

Fix circular ownership in FGFX

FGFX isA SGSampleGroup, but owns some SGXmlSounds, which also take an
owning ref to their sample group. Clear out the XMLSounds on unbind(),
to break the circular reference.
This commit is contained in:
James Turner 2020-08-11 14:06:15 +01:00
parent f8fcc8ff5d
commit 250669f75a

View file

@ -90,17 +90,17 @@ void FGFX::unbind()
{
_smgr->remove(_refname);
}
// because SGXmlSound has an owning ref back to us, we need to
// clear these here, or we will never get destroyed
std::for_each(_sound.begin(), _sound.end(), [](const SGXmlSound* snd) { delete snd; });
_sound.clear();
}
FGFX::~FGFX ()
{
for (unsigned int i = 0; i < _sound.size(); i++ ) {
delete _sound[i];
}
_sound.clear();
}
void
FGFX::init()
{
@ -156,9 +156,7 @@ FGFX::init()
void
FGFX::reinit()
{
for ( unsigned int i = 0; i < _sound.size(); i++ ) {
delete _sound[i];
}
std::for_each(_sound.begin(), _sound.end(), [](const SGXmlSound* snd) { delete snd; });
_sound.clear();
init();
}