1
0
mirror of synced 2025-01-19 01:24:15 +01:00

fix: Prevent same pl runtime from running simultaneously when loading provider

This commit is contained in:
WerWolv 2022-10-10 23:16:54 +02:00
parent ee2838bada
commit 1c52e0018a
2 changed files with 3 additions and 0 deletions

View File

@ -17,6 +17,7 @@ namespace hex::plugin::builtin {
struct {
std::string sourceCode;
std::mutex runtimeMutex;
std::unique_ptr<pl::PatternLanguage> runtime;
bool executionDone = true;
} patternLanguage;

View File

@ -123,6 +123,7 @@ namespace hex::plugin::builtin {
data.sourceCode = this->m_textEditor.GetText();
}
std::scoped_lock lock(data.runtimeMutex);
auto &runtime = data.runtime;
auto mimeType = magic::getMIMEType(provider);
@ -830,6 +831,7 @@ namespace hex::plugin::builtin {
EventManager::post<EventHighlightingChanged>();
TaskManager::createTask("hex.builtin.view.pattern_editor.evaluating", TaskManager::NoProgress, [this, &patternLanguage, code](auto &task) {
std::scoped_lock lock(patternLanguage.runtimeMutex);
auto &runtime = patternLanguage.runtime;
task.setInterruptCallback([&runtime] { runtime->abort(); });