diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index 26101f9270..487cf9137f 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -31,9 +31,11 @@ #include "unicode/resbund.h" #include "unicode/gregocal.h" #include "buddhcal.h" +#include "japancal.h" #include "unicode/calendar.h" #include "cpputils.h" #include "iculserv.h" +#include "ucln_in.h" U_NAMESPACE_BEGIN @@ -113,10 +115,8 @@ protected: if(!fType || !*fType || !strcmp(fType,"gregorian")) { // Gregorian (default) return new GregorianCalendar(canLoc, status); -# if 0 } else if(!strcmp(fType, "japanese")) { - return new JapaneseCalendar(loc, status); -#endif + return new JapaneseCalendar(canLoc, status); } else if(!strcmp(fType, "buddhist")) { return new BuddhistCalendar(canLoc, status); } else { @@ -250,7 +250,12 @@ static UMTX gnLock = 0; static ICULocaleService* getService(void) { - if (gService == NULL) { + UBool needInit; + { + Mutex mutex(&gnLock); + needInit = (UBool)(gService == NULL); + } + if (needInit) { UErrorCode status = U_ZERO_ERROR; #ifdef U_DEBUG_CALSVC fprintf(stderr, "Spinning up Calendar Service\n"); @@ -287,6 +292,7 @@ getService(void) if (newservice) { delete newservice; } + ucln_i18n_registerCleanup(); } return gService; } @@ -1171,6 +1177,15 @@ Calendar::updateTime(UErrorCode& status) U_NAMESPACE_END +U_CFUNC UBool calendar_cleanup(void) { + if (gService) { + delete gService; + gService = NULL; + } + umtx_destroy(&gnLock); + return TRUE; +} + #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/icu4c/source/i18n/ucln_in.c b/icu4c/source/i18n/ucln_in.c index 43a4733f29..58bf661ef5 100644 --- a/icu4c/source/i18n/ucln_in.c +++ b/icu4c/source/i18n/ucln_in.c @@ -28,6 +28,7 @@ static UBool i18n_cleanup(void) #endif #if !UCONFIG_NO_FORMATTING + calendar_cleanup(); numfmt_cleanup(); currency_cleanup(); timeZone_cleanup(); diff --git a/icu4c/source/i18n/ucln_in.h b/icu4c/source/i18n/ucln_in.h index bcf6eb08d8..68d899baae 100644 --- a/icu4c/source/i18n/ucln_in.h +++ b/icu4c/source/i18n/ucln_in.h @@ -30,6 +30,8 @@ U_CFUNC UBool timeZone_cleanup(void); U_CFUNC UBool numfmt_cleanup(void); +U_CFUNC UBool calendar_cleanup(void); + U_CFUNC UBool currency_cleanup(void); U_CFUNC UBool collator_cleanup(void);