thread linker doesn't append sentences anymore
This commit is contained in:
parent
535dac480a
commit
9711ce94c9
@ -70,6 +70,14 @@ void TextThread::Push(BYTE* data, int length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextThread::Push(const wchar_t* data)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(bufferMutex);
|
||||||
|
// not sure if this should filter repetition
|
||||||
|
lastPushTime = GetTickCount();
|
||||||
|
buffer += data;
|
||||||
|
}
|
||||||
|
|
||||||
void TextThread::Flush()
|
void TextThread::Flush()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
void Stop();
|
void Stop();
|
||||||
void AddSentence(std::wstring sentence);
|
void AddSentence(std::wstring sentence);
|
||||||
void Push(BYTE* data, int length);
|
void Push(BYTE* data, int length);
|
||||||
|
void Push(const wchar_t* data);
|
||||||
|
|
||||||
Synchronized<std::wstring> storage;
|
Synchronized<std::wstring> storage;
|
||||||
const int64_t handle;
|
const int64_t handle;
|
||||||
|
@ -105,6 +105,10 @@ namespace
|
|||||||
|
|
||||||
std::array<InfoForExtension, 10> GetSentenceInfo(TextThread& thread)
|
std::array<InfoForExtension, 10> GetSentenceInfo(TextThread& thread)
|
||||||
{
|
{
|
||||||
|
void (*AddText)(int64_t, const wchar_t*) = [](int64_t number, const wchar_t* text)
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(This, [number, text = std::wstring(text)] { if (TextThread* thread = Host::GetThread(number)) thread->Push(text.c_str()); });
|
||||||
|
};
|
||||||
void (*AddSentence)(int64_t, const wchar_t*) = [](int64_t number, const wchar_t* sentence)
|
void (*AddSentence)(int64_t, const wchar_t*) = [](int64_t number, const wchar_t* sentence)
|
||||||
{
|
{
|
||||||
// pointer from Host::GetThread may not stay valid unless on main thread
|
// pointer from Host::GetThread may not stay valid unless on main thread
|
||||||
@ -121,6 +125,7 @@ namespace
|
|||||||
{ "text handle", thread.handle },
|
{ "text handle", thread.handle },
|
||||||
{ "text name", (int64_t)thread.name.c_str() },
|
{ "text name", (int64_t)thread.name.c_str() },
|
||||||
{ "void (*AddSentence)(int64_t number, const wchar_t* sentence)", (int64_t)AddSentence },
|
{ "void (*AddSentence)(int64_t number, const wchar_t* sentence)", (int64_t)AddSentence },
|
||||||
|
{ "void (*AddText)(int64_t number, const wchar_t* text)", (int64_t)AddText },
|
||||||
{ "DWORD (*GetSelectedProcessId)()", (int64_t)GetSelectedProcessId },
|
{ "DWORD (*GetSelectedProcessId)()", (int64_t)GetSelectedProcessId },
|
||||||
{ nullptr, 0 } // nullptr marks end of info array
|
{ nullptr, 0 } // nullptr marks end of info array
|
||||||
} };
|
} };
|
||||||
|
@ -62,7 +62,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
|||||||
int64_t textHandle = sentenceInfo["text number"];
|
int64_t textHandle = sentenceInfo["text number"];
|
||||||
|
|
||||||
for (auto linkedHandle : linkedTextHandles[textHandle])
|
for (auto linkedHandle : linkedTextHandles[textHandle])
|
||||||
((void(*)(int64_t, const wchar_t*))sentenceInfo["void (*AddSentence)(int64_t number, const wchar_t* sentence)"])(linkedHandle, sentence.c_str());
|
((void(*)(int64_t, const wchar_t*))sentenceInfo["void (*AddText)(int64_t number, const wchar_t* text)"])(linkedHandle, sentence.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user