Locale Kit: move catalog add-ons loading to early initialization
The catalog loading has been done lazily since forever (this code was imported from OpenTracker). It results in a race condition as explained in #16670. Moving the catalog loading earlier in the locale loading process avoids this problem, since load_add_on is called before the locale roster lock is used. This should fix #16670. Change-Id: If07054077f7dde41cb342a43af2abe8422239b05 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3661 Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
2028d6386c
commit
4cf4daf212
@@ -446,7 +446,7 @@ BLocaleRoster::GetAvailableCatalogs(BMessage* languageList,
|
|||||||
CatalogAddOnInfo* info
|
CatalogAddOnInfo* info
|
||||||
= (CatalogAddOnInfo*)fData->fCatalogAddOnInfos.ItemAt(i);
|
= (CatalogAddOnInfo*)fData->fCatalogAddOnInfos.ItemAt(i);
|
||||||
|
|
||||||
if (!info->MakeSureItsLoaded() || !info->fLanguagesFunc)
|
if (!info->fLanguagesFunc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
info->fLanguagesFunc(languageList, sigPattern, langPattern,
|
info->fLanguagesFunc(languageList, sigPattern, langPattern,
|
||||||
|
|||||||
@@ -402,8 +402,12 @@ LocaleRosterData::_InitializeCatalogAddOns()
|
|||||||
CatalogAddOnInfo* addOnInfo
|
CatalogAddOnInfo* addOnInfo
|
||||||
= new(std::nothrow) CatalogAddOnInfo(dent->d_name,
|
= new(std::nothrow) CatalogAddOnInfo(dent->d_name,
|
||||||
addOnFolderName, priority);
|
addOnFolderName, priority);
|
||||||
if (addOnInfo)
|
if (addOnInfo != NULL) {
|
||||||
fCatalogAddOnInfos.AddItem((void*)addOnInfo);
|
if (addOnInfo->MakeSureItsLoaded())
|
||||||
|
fCatalogAddOnInfos.AddItem((void*)addOnInfo);
|
||||||
|
else
|
||||||
|
delete addOnInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Bump the dirent-pointer by length of the dirent just handled:
|
// Bump the dirent-pointer by length of the dirent just handled:
|
||||||
|
|||||||
@@ -150,8 +150,7 @@ MutableLocaleRoster::CreateCatalog(const char* type, const char* signature,
|
|||||||
for (int32 i = 0; i < count; ++i) {
|
for (int32 i = 0; i < count; ++i) {
|
||||||
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
||||||
fData->fCatalogAddOnInfos.ItemAt(i);
|
fData->fCatalogAddOnInfos.ItemAt(i);
|
||||||
if (info->fName.ICompare(type) != 0 || !info->MakeSureItsLoaded()
|
if (info->fName.ICompare(type) != 0 || !info->fCreateFunc)
|
||||||
|| !info->fCreateFunc)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BCatalogData* catalog = info->fCreateFunc(signature, language);
|
BCatalogData* catalog = info->fCreateFunc(signature, language);
|
||||||
@@ -189,7 +188,7 @@ MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner,
|
|||||||
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
||||||
fData->fCatalogAddOnInfos.ItemAt(i);
|
fData->fCatalogAddOnInfos.ItemAt(i);
|
||||||
|
|
||||||
if (!info->MakeSureItsLoaded() || !info->fInstantiateFunc)
|
if (!info->fInstantiateFunc)
|
||||||
continue;
|
continue;
|
||||||
BMessage languages;
|
BMessage languages;
|
||||||
if (language != NULL) {
|
if (language != NULL) {
|
||||||
@@ -277,8 +276,7 @@ MutableLocaleRoster::LoadCatalog(const char* signature,
|
|||||||
for (int32 i = 0; i < count; ++i) {
|
for (int32 i = 0; i < count; ++i) {
|
||||||
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
||||||
fData->fCatalogAddOnInfos.ItemAt(i);
|
fData->fCatalogAddOnInfos.ItemAt(i);
|
||||||
if (info->MakeSureItsLoaded()
|
if (info->fInstantiateFunc
|
||||||
&& info->fInstantiateFunc
|
|
||||||
== BPrivate::DefaultCatalog::Instantiate) {
|
== BPrivate::DefaultCatalog::Instantiate) {
|
||||||
defaultCatalogInfo = info;
|
defaultCatalogInfo = info;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user