!48240 [Bug]: 修复卡片多线程设置语言踩内存问题

Merge pull request !48240 from llzr/lzr62
This commit is contained in:
openharmony_ci 2024-11-12 06:31:58 +00:00 committed by Gitee
commit 39380429d0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 1 deletions

View File

@ -60,6 +60,7 @@ void AceApplicationInfoImpl::ChangeLocale(const std::string& language, const std
void AceApplicationInfoImpl::SetLocale(const std::string& language, const std::string& countryOrRegion,
const std::string& script, const std::string& keywordsAndValues)
{
std::unique_lock<std::shared_mutex> lock(localeTagMutex_);
language_ = language;
countryOrRegion_ = countryOrRegion;
script_ = script;

View File

@ -18,15 +18,18 @@
#include <chrono>
#include <cstdint>
#include <mutex>
#include <set>
#include <shared_mutex>
#include <string>
#include <vector>
#include "interfaces/inner_api/ace/ace_forward_compatibility.h"
#include "base/json/json_util.h"
#include "base/utils/macros.h"
#include "base/utils/noncopyable.h"
#include "base/utils/string_utils.h"
#include "interfaces/inner_api/ace/ace_forward_compatibility.h"
namespace OHOS::Ace {
@ -145,6 +148,7 @@ public:
const std::string& GetLocaleTag() const
{
std::shared_lock<std::shared_mutex> lock(localeTagMutex_);
return localeTag_;
}
@ -228,6 +232,7 @@ protected:
std::string language_;
std::string script_;
std::string localeTag_;
mutable std::shared_mutex localeTagMutex_;
std::string keywordsAndValues_;
std::string packageName_;