!138 fix xts system crash

Merge pull request !138 from sunyaozu/master
This commit is contained in:
openharmony_ci 2022-01-07 07:39:09 +00:00 committed by Gitee
commit af27c8d729
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 2 additions and 12 deletions

View File

@ -60,7 +60,6 @@ private:
std::string numeric = "always";
std::string numberingSystem;
LocaleInfo *localeInfo = nullptr;
icu::NumberFormat *numberFormat = nullptr;
icu::RelativeDateTimeFormatter *relativeTimeFormat = nullptr;
UDateRelativeDateTimeFormatterStyle style = UDAT_STYLE_LONG;
static std::unordered_map<std::string, URelativeDateTimeUnit> relativeUnits;

View File

@ -59,11 +59,7 @@ RelativeTimeFormat::RelativeTimeFormat(const std::vector<std::string> &localeTag
localeInfo = new LocaleInfo(curLocale, configs);
locale = localeInfo->GetLocale();
localeBaseName = localeInfo->GetBaseName();
numberFormat = icu::NumberFormat::createInstance(locale, UNUM_DECIMAL, status);
if (numberFormat == nullptr) {
continue;
}
relativeTimeFormat = new icu::RelativeDateTimeFormatter(locale, numberFormat, style,
relativeTimeFormat = new icu::RelativeDateTimeFormatter(locale, nullptr, style,
UDISPCTX_CAPITALIZATION_NONE, status);
break;
}
@ -72,8 +68,7 @@ RelativeTimeFormat::RelativeTimeFormat(const std::vector<std::string> &localeTag
localeInfo = new LocaleInfo(LocaleConfig::GetSystemLocale(), configs);
locale = localeInfo->GetLocale();
localeBaseName = localeInfo->GetBaseName();
numberFormat = icu::NumberFormat::createInstance(locale, UNUM_DECIMAL, status);
relativeTimeFormat = new icu::RelativeDateTimeFormatter(locale, numberFormat, style,
relativeTimeFormat = new icu::RelativeDateTimeFormatter(locale, nullptr, style,
UDISPCTX_CAPITALIZATION_NONE, status);
}
numberingSystem = localeInfo->GetNumberingSystem();
@ -88,10 +83,6 @@ RelativeTimeFormat::~RelativeTimeFormat()
delete localeInfo;
localeInfo = nullptr;
}
if (numberFormat != nullptr) {
delete numberFormat;
numberFormat = nullptr;
}
if (relativeTimeFormat != nullptr) {
delete relativeTimeFormat;
relativeTimeFormat = nullptr;