Just on a hunch, do you have a BApplication active when this is faliing? >Noone from the Translation Kit team could figure this one out, so I >thought that I would take my question to the "main" list. > >I simply cannon instantiate a BTranslatorRoster. > >Ordinarily BArchivable extended classes, may be archived using the >Archive(BMessage* message) method and instantiated using the >Instantiate(BMessage* message) method. > >Thus the following should work fine (it does not!) >BTranslatorRoster* translator_roster = NULL; >BMessage translator_message; > >translator_roster = new BTranslatorRoster(); >translator_roster->AddTranslators("/boot/home/config/add-ons/ >Translators/"); >.. >//verify that translators are actually loaded >.. > >//archive the sucker >translator_roster->Archive(&translator_message); > >//delete old translator_roster and reinstantiate >delete translator_roster; >translator_roster = (BTranslatorRoster*) >BTranslatorRoster::Instantiate(&translator_message); > >translator_roster is now NULL - how come???? > >Ok, so I tested an alternative, reading the docs >BTranslatorRoster::Instantiate says: >Returns a new BTranslatorRoster object, allocated by new and created >with the version of the constructor that takes a BMessage archive. >However, if the archive doesn't contain data for a BTranslatorRoster >object, Instantiate() returns NULL > >If this is the case - then the following should work: > >translator_message.AddString("be:translator_path", "/boot/home/config/ >add-ons/Translators/"); >translator_roster = (BTranslatorRoster*) >BTranslatorRoster::Instantiate(&translator_message); > >but it doesn't *ponder!* > >the actual instantiate test is available from CVS (openbeos/sources/os/ >kits/translation/tests/) > - the method in question is: >status_t TranslatorRosterTest::InstantiateTest() >however this only contains the latter of the tests. So for >completeness, this is the first test: >-- 8< -- >translator_roster = new BTranslatorRoster(); >translator_roster->AddTranslators("/boot/home/config/add-ons/ >Translators/"); > > //write it to output > if(translator_roster != NULL) { > int32 num_translators; > translator_id* translators; > translator_roster->GetAllTranslators(&translators, & >num_translators); > if(num_translators <= 0) { > Debug("Unable to load translators, or no translators >installed\n"); > return B_ERROR; > } else { > printf("%ld translator(s) loaded\n", num_translators); > } > delete [] translators; > } else { > printf("Unable to instantiate translator roster\n"); > } > translator_roster->Archive(&translator_message); > > delete translator_roster; > > //instantiate > translator_roster = (BTranslatorRoster*) >BTranslatorRoster::Instantiate(&translator_message); >if(translator_roster != NULL) { > int32 num_translators; > translator_id* translators; > translator_roster->GetAllTranslators(&translators, & >num_translators); > if(num_translators <= 0) { > Debug("Unable to load translators, or no translators >installed\n"); > return B_ERROR; > } else { > printf("%ld loaded\n", num_translators); > } > delete [] translators; > } else { > printf("Unable to instantiate translator roster\n"); > } >-- 8< -- > > >