Don't try to clean up the async ringbuffer if it isn't allocated

This commit is contained in:
Chris Robinson 2019-01-26 19:29:26 -08:00
parent f5e17bafea
commit f98a24fb8a

View File

@ -2452,24 +2452,27 @@ ALCcontext::~ALCcontext()
}
TRACE("Freed " SZFMT " listener property object%s\n", count, (count==1)?"":"s");
count = 0;
auto evt_vec = AsyncEvents->getReadVector();
while(evt_vec.first.len > 0)
if(AsyncEvents)
{
reinterpret_cast<AsyncEvent*>(evt_vec.first.buf)->~AsyncEvent();
evt_vec.first.buf += sizeof(AsyncEvent);
evt_vec.first.len -= 1;
++count;
count = 0;
auto evt_vec = AsyncEvents->getReadVector();
while(evt_vec.first.len > 0)
{
reinterpret_cast<AsyncEvent*>(evt_vec.first.buf)->~AsyncEvent();
evt_vec.first.buf += sizeof(AsyncEvent);
evt_vec.first.len -= 1;
++count;
}
while(evt_vec.second.len > 0)
{
reinterpret_cast<AsyncEvent*>(evt_vec.second.buf)->~AsyncEvent();
evt_vec.second.buf += sizeof(AsyncEvent);
evt_vec.second.len -= 1;
++count;
}
if(count > 0)
TRACE("Destructed " SZFMT " orphaned event%s\n", count, (count==1)?"":"s");
}
while(evt_vec.second.len > 0)
{
reinterpret_cast<AsyncEvent*>(evt_vec.second.buf)->~AsyncEvent();
evt_vec.second.buf += sizeof(AsyncEvent);
evt_vec.second.len -= 1;
++count;
}
if(count > 0)
TRACE("Destructed " SZFMT " orphaned event%s\n", count, (count==1)?"":"s");
ALCdevice_DecRef(Device);
}