"Fixed" BTranslatorRoster so that it no longer stores the list of translators backwards. This is the order that applications assume, so this must be done to prevent inconsistent behavior between the R5 translation kit and the Haiku version.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9490 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -218,14 +218,17 @@ private:
|
|||||||
|
|
||||||
static BTranslatorRoster *fspDefaultTranslators;
|
static BTranslatorRoster *fspDefaultTranslators;
|
||||||
// object that contains the default translators
|
// object that contains the default translators
|
||||||
|
|
||||||
|
// list of translators maintained by this object
|
||||||
translator_node *fpTranslators;
|
translator_node *fpTranslators;
|
||||||
// list of translators maintained by this object
|
translator_node *fpLastTranslator;
|
||||||
|
|
||||||
sem_id fSem;
|
sem_id fSem;
|
||||||
// semaphore used to lock this object
|
// semaphore used to lock this object
|
||||||
|
|
||||||
// used to maintain binary combatibility with
|
// used to maintain binary combatibility with
|
||||||
// past and future versions of this object
|
// past and future versions of this object
|
||||||
int32 fUnused[5];
|
int32 fUnused[4];
|
||||||
virtual void ReservedTranslatorRoster1();
|
virtual void ReservedTranslatorRoster1();
|
||||||
virtual void ReservedTranslatorRoster2();
|
virtual void ReservedTranslatorRoster2();
|
||||||
virtual void ReservedTranslatorRoster3();
|
virtual void ReservedTranslatorRoster3();
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ BTranslatorRoster::BTranslatorRoster(BMessage *model) : BArchivable()
|
|||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
void BTranslatorRoster::Initialize()
|
void BTranslatorRoster::Initialize()
|
||||||
{
|
{
|
||||||
fpTranslators = NULL;
|
fpTranslators = fpLastTranslator = NULL;
|
||||||
fSem = create_sem(1, "BTranslatorRoster Lock");
|
fSem = create_sem(1, "BTranslatorRoster Lock");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ BTranslatorRoster::~BTranslatorRoster()
|
|||||||
delete pDelTranNode;
|
delete pDelTranNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
fpTranslators = NULL;
|
fpTranslators = fpLastTranslator = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_sem(fSem);
|
delete_sem(fSem);
|
||||||
@@ -823,12 +823,11 @@ BTranslatorRoster::GetAllTranslators(
|
|||||||
translator_node *pTranNode = NULL;
|
translator_node *pTranNode = NULL;
|
||||||
for (pTranNode = fpTranslators; pTranNode; pTranNode = pTranNode->next)
|
for (pTranNode = fpTranslators; pTranNode; pTranNode = pTranNode->next)
|
||||||
(*outCount)++;
|
(*outCount)++;
|
||||||
// because translators are stored in the list backwards,
|
// populate the outList
|
||||||
// populate the outList backwards to produce the original order
|
|
||||||
*outList = new translator_id[*outCount];
|
*outList = new translator_id[*outCount];
|
||||||
int32 i = (*outCount) - 1;
|
int32 i = 0;
|
||||||
for (pTranNode = fpTranslators; pTranNode; pTranNode = pTranNode->next)
|
for (pTranNode = fpTranslators; pTranNode; pTranNode = pTranNode->next)
|
||||||
(*outList)[i--] = pTranNode->id;
|
(*outList)[i++] = pTranNode->id;
|
||||||
|
|
||||||
result = B_NO_ERROR;
|
result = B_NO_ERROR;
|
||||||
release_sem(fSem);
|
release_sem(fSem);
|
||||||
@@ -1606,15 +1605,20 @@ BTranslatorRoster::AddTranslatorToList(BTranslator *translator,
|
|||||||
pTranNode->translator = translator;
|
pTranNode->translator = translator;
|
||||||
|
|
||||||
if (fpTranslators)
|
if (fpTranslators)
|
||||||
pTranNode->id = fpTranslators->id + 1;
|
pTranNode->id = fpLastTranslator->id + 1;
|
||||||
else
|
else
|
||||||
pTranNode->id = 1;
|
pTranNode->id = 1;
|
||||||
|
|
||||||
pTranNode->path = new char[strlen(path) + 1];
|
pTranNode->path = new char[strlen(path) + 1];
|
||||||
strcpy(pTranNode->path, path);
|
strcpy(pTranNode->path, path);
|
||||||
pTranNode->image = image;
|
pTranNode->image = image;
|
||||||
pTranNode->next = fpTranslators;
|
pTranNode->next = NULL;
|
||||||
fpTranslators = pTranNode;
|
if (!fpTranslators)
|
||||||
|
fpTranslators = fpLastTranslator = pTranNode;
|
||||||
|
else {
|
||||||
|
fpLastTranslator->next = pTranNode;
|
||||||
|
fpLastTranslator = pTranNode;
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user