"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:
Matthew Wilber
2004-10-24 19:42:05 +00:00
parent 5486bd24bf
commit a689e076c3
2 changed files with 18 additions and 11 deletions
+5 -2
View File
@@ -218,14 +218,17 @@ private:
static BTranslatorRoster *fspDefaultTranslators;
// object that contains the default translators
// list of translators maintained by this object
translator_node *fpTranslators;
// list of translators maintained by this object
translator_node *fpLastTranslator;
sem_id fSem;
// semaphore used to lock this object
// used to maintain binary combatibility with
// past and future versions of this object
int32 fUnused[5];
int32 fUnused[4];
virtual void ReservedTranslatorRoster1();
virtual void ReservedTranslatorRoster2();
virtual void ReservedTranslatorRoster3();
+13 -9
View File
@@ -157,7 +157,7 @@ BTranslatorRoster::BTranslatorRoster(BMessage *model) : BArchivable()
// ---------------------------------------------------------------
void BTranslatorRoster::Initialize()
{
fpTranslators = NULL;
fpTranslators = fpLastTranslator = NULL;
fSem = create_sem(1, "BTranslatorRoster Lock");
}
@@ -212,7 +212,7 @@ BTranslatorRoster::~BTranslatorRoster()
delete pDelTranNode;
}
fpTranslators = NULL;
fpTranslators = fpLastTranslator = NULL;
}
delete_sem(fSem);
@@ -823,12 +823,11 @@ BTranslatorRoster::GetAllTranslators(
translator_node *pTranNode = NULL;
for (pTranNode = fpTranslators; pTranNode; pTranNode = pTranNode->next)
(*outCount)++;
// because translators are stored in the list backwards,
// populate the outList backwards to produce the original order
// populate the outList
*outList = new translator_id[*outCount];
int32 i = (*outCount) - 1;
int32 i = 0;
for (pTranNode = fpTranslators; pTranNode; pTranNode = pTranNode->next)
(*outList)[i--] = pTranNode->id;
(*outList)[i++] = pTranNode->id;
result = B_NO_ERROR;
release_sem(fSem);
@@ -1606,15 +1605,20 @@ BTranslatorRoster::AddTranslatorToList(BTranslator *translator,
pTranNode->translator = translator;
if (fpTranslators)
pTranNode->id = fpTranslators->id + 1;
pTranNode->id = fpLastTranslator->id + 1;
else
pTranNode->id = 1;
pTranNode->path = new char[strlen(path) + 1];
strcpy(pTranNode->path, path);
pTranNode->image = image;
pTranNode->next = fpTranslators;
fpTranslators = pTranNode;
pTranNode->next = NULL;
if (!fpTranslators)
fpTranslators = fpLastTranslator = pTranNode;
else {
fpLastTranslator->next = pTranNode;
fpLastTranslator = pTranNode;
}
return B_OK;
}