This commit is contained in:
Akash Mozumdar 2018-10-09 02:09:52 -04:00
parent 0166df7209
commit 967f75a5ec
3 changed files with 9 additions and 9 deletions

View File

@ -7,7 +7,7 @@
#include "const.h" #include "const.h"
#include <regex> #include <regex>
TextThread::TextThread(ThreadParam tp, DWORD status) : handle(ThreadCounter++), name(Host::GetHookName(tp.pid, tp.hook)), tp(tp), status(status) {} TextThread::TextThread(ThreadParam tp, DWORD status) : handle(threadCounter++), name(Host::GetHookName(tp.pid, tp.hook)), tp(tp), status(status) {}
TextThread::~TextThread() TextThread::~TextThread()
{ {
@ -27,7 +27,7 @@ void TextThread::Flush()
std::wstring sentence; std::wstring sentence;
{ {
LOCK(ttMutex); LOCK(ttMutex);
if (buffer.size() < MaxBufferSize && (GetTickCount() - timestamp < FlushDelay || buffer.size() < 2)) return; if (buffer.size() < maxBufferSize && GetTickCount() - timestamp < flushDelay) return;
sentence = buffer; sentence = buffer;
buffer.clear(); buffer.clear();
} }

View File

@ -15,9 +15,9 @@ public:
inline static OutputCallback Output; inline static OutputCallback Output;
inline static std::wstring filter = L""; inline static std::wstring filter = L"";
inline static int FlushDelay = 250; // flush every 250ms by default inline static int flushDelay = 250; // flush every 250ms by default
inline static int MaxBufferSize = 200; inline static int maxBufferSize = 200;
inline static int ThreadCounter = 0; inline static int threadCounter = 0;
TextThread(ThreadParam tp, DWORD status); TextThread(ThreadParam tp, DWORD status);
~TextThread(); ~TextThread();

View File

@ -13,8 +13,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect()); if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect());
// TODO: add GUI for changing these // TODO: add GUI for changing these
if (settings.contains("Flush_Delay")) TextThread::FlushDelay = settings.value("Flush_Delay").toInt(); if (settings.contains("Flush_Delay")) TextThread::flushDelay = settings.value("Flush_Delay").toInt();
if (settings.contains("Max_Buffer_Size")) TextThread::MaxBufferSize = settings.value("Max_Buffer_Size").toInt(); if (settings.contains("Max_Buffer_Size")) TextThread::maxBufferSize = settings.value("Max_Buffer_Size").toInt();
processCombo = findChild<QComboBox*>("processCombo"); processCombo = findChild<QComboBox*>("processCombo");
ttCombo = findChild<QComboBox*>("ttCombo"); ttCombo = findChild<QComboBox*>("ttCombo");
@ -41,8 +41,8 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
settings.setValue("Window", this->geometry()); settings.setValue("Window", this->geometry());
settings.setValue("Flush_Delay", TextThread::FlushDelay); settings.setValue("Flush_Delay", TextThread::flushDelay);
settings.setValue("Max_Buffer_Size", TextThread::MaxBufferSize); settings.setValue("Max_Buffer_Size", TextThread::maxBufferSize);
settings.sync(); settings.sync();
Host::Close(); Host::Close();
delete ui; delete ui;