mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Fix a bug related to trashed keys. (cherry picked from H'uru e2b5786988
)
It appears that the hsTArray memory management really sucks for smart pointers like plKey. The crash mentioned at http://forum.guildofwriters.org/viewtopic.php?f=117&t=6291 went away immediately after switching plKeyCollector to an std::set.
This commit is contained in:
@ -155,7 +155,7 @@ int main(int argc, char* argv[])
|
||||
class plSoundBufferCollector : public plRegistryPageIterator, public plKeyCollector
|
||||
{
|
||||
public:
|
||||
plSoundBufferCollector(hsTArray<plKey>& keyArray)
|
||||
plSoundBufferCollector(std::set<plKey>& keyArray)
|
||||
: plKeyCollector(keyArray) {}
|
||||
|
||||
hsBool EatPage(plRegistryPageNode* page)
|
||||
@ -169,14 +169,14 @@ public:
|
||||
|
||||
bool DumpSounds()
|
||||
{
|
||||
hsTArray<plKey> soundKeys;
|
||||
std::set<plKey> soundKeys;
|
||||
|
||||
plSoundBufferCollector soundCollector(soundKeys);
|
||||
gResMgr->IterateAllPages(&soundCollector);
|
||||
|
||||
for (int i = 0; i < soundKeys.GetCount(); i++)
|
||||
for (std::set<plKey>::iterator it = soundKeys.begin(); it != soundKeys.end(); ++it)
|
||||
{
|
||||
plSoundBuffer* buffer = plSoundBuffer::ConvertNoRef(soundKeys[i]->VerifyLoaded());
|
||||
plSoundBuffer* buffer = plSoundBuffer::ConvertNoRef((*it)->VerifyLoaded());
|
||||
if (buffer)
|
||||
{
|
||||
// Ref it...
|
||||
@ -207,7 +207,7 @@ bool DumpSounds()
|
||||
}
|
||||
}
|
||||
|
||||
soundKeys.Reset();
|
||||
soundKeys.clear();
|
||||
plIndirectUnloadIterator iter;
|
||||
gResMgr->IterateAllPages(&iter);
|
||||
|
||||
@ -267,4 +267,4 @@ bool DumpStats(const char* patchDir)
|
||||
plStatDumpIterator statDump(patchDir);
|
||||
gResMgr->IterateAllPages(&statDump);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user