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*)fData->fCatalogAddOnInfos.ItemAt(i);
|
||||
|
||||
if (!info->MakeSureItsLoaded() || !info->fLanguagesFunc)
|
||||
if (!info->fLanguagesFunc)
|
||||
continue;
|
||||
|
||||
info->fLanguagesFunc(languageList, sigPattern, langPattern,
|
||||
|
||||
@@ -402,8 +402,12 @@ LocaleRosterData::_InitializeCatalogAddOns()
|
||||
CatalogAddOnInfo* addOnInfo
|
||||
= new(std::nothrow) CatalogAddOnInfo(dent->d_name,
|
||||
addOnFolderName, priority);
|
||||
if (addOnInfo)
|
||||
fCatalogAddOnInfos.AddItem((void*)addOnInfo);
|
||||
if (addOnInfo != NULL) {
|
||||
if (addOnInfo->MakeSureItsLoaded())
|
||||
fCatalogAddOnInfos.AddItem((void*)addOnInfo);
|
||||
else
|
||||
delete addOnInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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) {
|
||||
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
||||
fData->fCatalogAddOnInfos.ItemAt(i);
|
||||
if (info->fName.ICompare(type) != 0 || !info->MakeSureItsLoaded()
|
||||
|| !info->fCreateFunc)
|
||||
if (info->fName.ICompare(type) != 0 || !info->fCreateFunc)
|
||||
continue;
|
||||
|
||||
BCatalogData* catalog = info->fCreateFunc(signature, language);
|
||||
@@ -189,7 +188,7 @@ MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner,
|
||||
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
||||
fData->fCatalogAddOnInfos.ItemAt(i);
|
||||
|
||||
if (!info->MakeSureItsLoaded() || !info->fInstantiateFunc)
|
||||
if (!info->fInstantiateFunc)
|
||||
continue;
|
||||
BMessage languages;
|
||||
if (language != NULL) {
|
||||
@@ -277,8 +276,7 @@ MutableLocaleRoster::LoadCatalog(const char* signature,
|
||||
for (int32 i = 0; i < count; ++i) {
|
||||
CatalogAddOnInfo* info = (CatalogAddOnInfo*)
|
||||
fData->fCatalogAddOnInfos.ItemAt(i);
|
||||
if (info->MakeSureItsLoaded()
|
||||
&& info->fInstantiateFunc
|
||||
if (info->fInstantiateFunc
|
||||
== BPrivate::DefaultCatalog::Instantiate) {
|
||||
defaultCatalogInfo = info;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user