forked from Public-Mirror/Textractor
refactor
This commit is contained in:
parent
69e01dab7c
commit
8e45b35ebe
@ -44,12 +44,12 @@ namespace
|
|||||||
{
|
{
|
||||||
LOCK(hostMutex);
|
LOCK(hostMutex);
|
||||||
std::vector<ThreadParam> removedThreads;
|
std::vector<ThreadParam> removedThreads;
|
||||||
for (auto i : textThreadsByParams)
|
for (auto[tp, thread] : textThreadsByParams)
|
||||||
if (removeIf(i.first))
|
if (removeIf(tp))
|
||||||
{
|
{
|
||||||
OnRemove(i.second);
|
OnRemove(thread);
|
||||||
//delete i.second; // Artikash 7/24/2018: FIXME: Qt GUI updates on another thread, so I can't delete this yet.
|
//delete i.second; // Artikash 7/24/2018: FIXME: Qt GUI updates on another thread, so I can't delete this yet.
|
||||||
removedThreads.push_back(i.first);
|
removedThreads.push_back(tp);
|
||||||
}
|
}
|
||||||
for (auto thread : removedThreads) textThreadsByParams.erase(thread);
|
for (auto thread : removedThreads) textThreadsByParams.erase(thread);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ namespace Host
|
|||||||
#ifdef _DEBUG // Check memory leaks
|
#ifdef _DEBUG // Check memory leaks
|
||||||
LOCK(hostMutex);
|
LOCK(hostMutex);
|
||||||
OnRemove = [](TextThread* textThread) { delete textThread; };
|
OnRemove = [](TextThread* textThread) { delete textThread; };
|
||||||
for (auto i : processRecordsByIds) UnregisterProcess(i.first);
|
for (auto[pid, pr] : processRecordsByIds) UnregisterProcess(pid);
|
||||||
delete textThreadsByParams[CONSOLE];
|
delete textThreadsByParams[CONSOLE];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
49
GUI/main.cpp
49
GUI/main.cpp
@ -2,36 +2,39 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
char* GetCppExceptionInfo(EXCEPTION_POINTERS* exception)
|
namespace
|
||||||
{
|
{
|
||||||
// See https://blogs.msdn.microsoft.com/oldnewthing/20100730-00/?p=13273
|
char* GetCppExceptionInfo(EXCEPTION_POINTERS* exception)
|
||||||
// Not very reliable so use __try
|
{
|
||||||
__try { return ((char****)exception->ExceptionRecord->ExceptionInformation[2])[3][1][1] + 8; }
|
// See https://blogs.msdn.microsoft.com/oldnewthing/20100730-00/?p=13273
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER) { return "Could not find"; }
|
// Not very reliable so use __try
|
||||||
}
|
__try { return ((char****)exception->ExceptionRecord->ExceptionInformation[2])[3][1][1] + 8; }
|
||||||
|
__except (EXCEPTION_EXECUTE_HANDLER) { return "Could not find"; }
|
||||||
|
}
|
||||||
|
|
||||||
LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS* exception)
|
LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS* exception)
|
||||||
{
|
{
|
||||||
MEMORY_BASIC_INFORMATION info = {};
|
MEMORY_BASIC_INFORMATION info = {};
|
||||||
VirtualQuery(exception->ExceptionRecord->ExceptionAddress, &info, sizeof(info));
|
VirtualQuery(exception->ExceptionRecord->ExceptionAddress, &info, sizeof(info));
|
||||||
wchar_t moduleName[MAX_PATH] = {};
|
wchar_t moduleName[MAX_PATH] = {};
|
||||||
GetModuleFileNameW((HMODULE)info.AllocationBase, moduleName, MAX_PATH);
|
GetModuleFileNameW((HMODULE)info.AllocationBase, moduleName, MAX_PATH);
|
||||||
|
|
||||||
std::wstringstream errorMsg;
|
std::wstringstream errorMsg;
|
||||||
errorMsg << std::uppercase << std::hex <<
|
errorMsg << std::uppercase << std::hex <<
|
||||||
L"Error code: " << exception->ExceptionRecord->ExceptionCode << std::endl <<
|
L"Error code: " << exception->ExceptionRecord->ExceptionCode << std::endl <<
|
||||||
L"Error address: " << (uint64_t)exception->ExceptionRecord->ExceptionAddress << std::endl <<
|
L"Error address: " << (uint64_t)exception->ExceptionRecord->ExceptionAddress << std::endl <<
|
||||||
L"Error in module: " << moduleName << std::endl;
|
L"Error in module: " << moduleName << std::endl;
|
||||||
|
|
||||||
if (exception->ExceptionRecord->ExceptionCode == 0xE06D7363)
|
if (exception->ExceptionRecord->ExceptionCode == 0xE06D7363)
|
||||||
errorMsg << "Additional info: " << GetCppExceptionInfo(exception) << std::endl;
|
errorMsg << "Additional info: " << GetCppExceptionInfo(exception) << std::endl;
|
||||||
|
|
||||||
for (int i = 0; i < exception->ExceptionRecord->NumberParameters; ++i)
|
for (int i = 0; i < exception->ExceptionRecord->NumberParameters; ++i)
|
||||||
errorMsg << L"Additional info: " << exception->ExceptionRecord->ExceptionInformation[i] << std::endl;
|
errorMsg << L"Additional info: " << exception->ExceptionRecord->ExceptionInformation[i] << std::endl;
|
||||||
|
|
||||||
MessageBoxW(NULL, errorMsg.str().c_str(), L"Textractor ERROR", MB_ICONERROR);
|
MessageBoxW(NULL, errorMsg.str().c_str(), L"Textractor ERROR", MB_ICONERROR);
|
||||||
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -6,8 +6,8 @@ bool RemoveRepeatedChars(std::wstring& sentence)
|
|||||||
{
|
{
|
||||||
int repeatNumber = 0;
|
int repeatNumber = 0;
|
||||||
wchar_t prevChar = sentence[0];
|
wchar_t prevChar = sentence[0];
|
||||||
for (auto i : sentence)
|
for (auto c : sentence)
|
||||||
if (i == prevChar) repeatNumber++;
|
if (c == prevChar) repeatNumber++;
|
||||||
else break;
|
else break;
|
||||||
if (repeatNumber == 1) return false;
|
if (repeatNumber == 1) return false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user