From 23336924484d5d10335d03d097e8b1e8b83ea896 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 19 Aug 2019 15:58:53 -0400 Subject: [PATCH] fix out of memory error when history size too low --- GUI/host/textthread.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GUI/host/textthread.cpp b/GUI/host/textthread.cpp index c12f3a8..8aced68 100644 --- a/GUI/host/textthread.cpp +++ b/GUI/host/textthread.cpp @@ -72,7 +72,10 @@ void TextThread::Push(BYTE* data, int length) 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 sentences; queuedSentences->swap(sentences);