ICU-2202 fix corner case where service has been started, but it calls back through handleDefault to makeInstance

X-SVN-Rev: 14386
This commit is contained in:
Alan Liu 2004-01-22 22:43:07 +00:00
parent f8d0532e9c
commit 4de846b86d

View File

@ -402,10 +402,22 @@ BreakIterator::createInstance(const Locale& loc, UBreakIteratorType kind, UError
u_init(&status);
if (hasService()) {
Locale validLoc;
BreakIterator *result = (BreakIterator*)gService->get(loc, kind, &validLoc, status);
Locale actualLoc;
BreakIterator *result = (BreakIterator*)gService->get(loc, kind, &actualLoc, status);
// TODO: The way the service code works in ICU 2.8 is that if
// there is a real registered break iterator, the actualLoc
// will be populated, but if the handleDefault path is taken
// (because nothing is registered that can handle the
// requested locale) then the actualLoc comes back empty. In
// that case, the returned object already has its actual/valid
// locale data populated (by makeInstance, which is what
// handleDefault calls), so we don't touch it. YES, A COMMENT
// THIS LONG is a sign of bad code -- so the action item is to
// revisit this in ICU 3.0 and clean it up/fix it/remove it.
if (*actualLoc.getName() != 0) {
U_LOCALE_BASED(locBased, *result);
locBased.setLocaleIDs(validLoc.getName(), 0);
locBased.setLocaleIDs(actualLoc.getName(), actualLoc.getName());
}
return result;
} else {
return makeInstance(loc, kind, status);