mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 18:59:09 +00:00
Fix a bug related to trashed keys.
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:
@ -145,7 +145,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) {}
|
||||
|
||||
bool EatPage(plRegistryPageNode* page)
|
||||
@ -159,14 +159,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 (auto it = soundKeys.begin(); it != soundKeys.end(); ++it)
|
||||
{
|
||||
plSoundBuffer* buffer = plSoundBuffer::ConvertNoRef(soundKeys[i]->VerifyLoaded());
|
||||
plSoundBuffer* buffer = plSoundBuffer::ConvertNoRef((*it)->VerifyLoaded());
|
||||
if (buffer)
|
||||
{
|
||||
// Ref it...
|
||||
@ -197,7 +197,7 @@ bool DumpSounds()
|
||||
}
|
||||
}
|
||||
|
||||
soundKeys.Reset();
|
||||
soundKeys.clear();
|
||||
plIndirectUnloadIterator iter;
|
||||
gResMgr->IterateAllPages(&iter);
|
||||
|
||||
|
Reference in New Issue
Block a user