fix out of memory error when history size too low

This commit is contained in:
Akash Mozumdar 2019-08-19 15:58:53 -04:00
parent c3274b8275
commit 2333692448

View File

@ -72,7 +72,10 @@ void TextThread::Push(BYTE* data, int length)
void TextThread::Flush() void TextThread::Flush()
{ {
if (storage->size() > maxHistorySize) storage->erase(0, maxHistorySize / 2); // https://github.com/Artikash/Textractor/issues/127#issuecomment-486882983 {
auto storage = this->storage.Acquire();
if (storage->size() > maxHistorySize) storage->erase(0, storage->size() - maxHistorySize); // https://github.com/Artikash/Textractor/issues/127#issuecomment-486882983
}
std::deque<std::wstring> sentences; std::deque<std::wstring> sentences;
queuedSentences->swap(sentences); queuedSentences->swap(sentences);