diff --git a/extensions/regexfilter.cpp b/extensions/regexfilter.cpp index 0d2e060..69c1522 100644 --- a/extensions/regexfilter.cpp +++ b/extensions/regexfilter.cpp @@ -24,7 +24,6 @@ public: ui.setupUi(this); connect(ui.regexEdit, &QLineEdit::textEdited, this, &Window::SetRegex); - connect(ui.replaceEdit, &QLineEdit::textEdited, this, &Window::SetReplace); connect(ui.saveButton, &QPushButton::clicked, this, &Window::Save); setWindowTitle(REGEX_FILTER); @@ -41,21 +40,13 @@ public: ui.output->setText(QString(CURRENT_FILTER).arg(regex)); } - void SetReplace(QString replace) - { - ui.replaceEdit->setText(replace); - std::scoped_lock lock(m); - ::replace = S(replace); - } - private: void Save() { auto formatted = FormatString( - L"\xfeff|PROCESS|%s|FILTER|%s|REPLACE|%s|END|\r\n", + L"\xfeff|PROCESS|%s|FILTER|%s|END|\r\n", GetModuleFilename(GetSelectedProcessId()).value_or(FormatString(L"Error getting name of process 0x%X", GetSelectedProcessId())), - S(ui.regexEdit->text()), - S(ui.replaceEdit->text()) + S(ui.regexEdit->text()) ); std::ofstream(REGEX_SAVE_FILE, std::ios::binary | std::ios::app).write((const char*)formatted.c_str(), formatted.size() * sizeof(wchar_t)); } @@ -70,16 +61,12 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) if (sentenceInfo["current select"] && !regex) if (auto processName = GetModuleFilename(sentenceInfo["process id"])) { std::ifstream stream(REGEX_SAVE_FILE, std::ios::binary); - BlockMarkupIterator savedFilters(stream, Array{ L"|PROCESS|", L"|FILTER|", L"|REPLACE|" }); - std::vector> regexes; - while (auto read = savedFilters.Next()) if (read->at(0) == processName) regexes.push_back(std::move(read.value())); - if (!regexes.empty()) QMetaObject::invokeMethod(&window, [regex = S(regexes.back()[1]), replace = S(regexes.back()[2])] - { - window.SetRegex(regex); - window.SetReplace(replace); - }, Qt::BlockingQueuedConnection); + BlockMarkupIterator savedFilters(stream, Array{ L"|PROCESS|", L"|FILTER|" }); + std::vector regexes; + while (auto read = savedFilters.Next()) if (read->at(0) == processName) regexes.push_back(std::move(read->at(1))); + if (!regexes.empty()) QMetaObject::invokeMethod(&window, std::bind(&Window::SetRegex, &window, S(regexes.back())), Qt::BlockingQueuedConnection); } - std::shared_lock l(m); + std::shared_lock lock(m); if (regex) sentence = std::regex_replace(sentence, regex.value(), replace); return true; } diff --git a/extensions/regexfilter.ui b/extensions/regexfilter.ui index e22914b..add034b 100644 --- a/extensions/regexfilter.ui +++ b/extensions/regexfilter.ui @@ -16,16 +16,6 @@ - - - - => - - - - - - diff --git a/extensions/replacer.cpp b/extensions/replacer.cpp index d317316..03ae8dc 100644 --- a/extensions/replacer.cpp +++ b/extensions/replacer.cpp @@ -121,7 +121,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo) { UpdateReplacements(); - std::shared_lock l(m); + std::shared_lock lock(m); sentence = trie.Replace(sentence); return true; } diff --git a/extensions/threadlinker.cpp b/extensions/threadlinker.cpp index 91dfff7..3f69000 100644 --- a/extensions/threadlinker.cpp +++ b/extensions/threadlinker.cpp @@ -57,7 +57,7 @@ private: bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) { - std::shared_lock l(m); + std::shared_lock lock(m); int64_t textHandle = sentenceInfo["text number"]; for (auto linkedHandle : linkedTextHandles[textHandle])