From cee70b6f53094469b1d26eb464c2af00f09c9ae8 Mon Sep 17 00:00:00 2001 From: ksqsf Date: Sun, 15 Dec 2024 20:13:00 +0100 Subject: [PATCH] fix: do not initialize rime multiple times --- src/rime.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rime.cpp b/src/rime.cpp index e96ace8..c87ec9f 100644 --- a/src/rime.cpp +++ b/src/rime.cpp @@ -1,8 +1,11 @@ #include +#include #include "rime.h" namespace fs = std::filesystem; +static std::atomic rime_initialized = false; + Rime::Rime(fs::path source_dir, const std::string& schema_id, std::optional cache_dir, @@ -32,8 +35,11 @@ Rime::Rime(fs::path source_dir, traits.user_data_dir = user_data_dir.c_str(); traits.log_dir = log_dir.c_str(); traits.staging_dir = staging_dir.c_str(); - api->setup(&traits); - api->initialize(NULL); + if (!rime_initialized.load()) { + api->setup(&traits); + api->initialize(NULL); + rime_initialized.store(true); + } if (deploy_now && api->start_maintenance(/* full_check */ true)) api->join_maintenance_thread(); }