Fix MutableLocaleRoster::GetSystemCatalog()

* Using a hardcoded path is bad, since the library folder might
  change and/or the /system/lib/libbe.so may not be the libbe.so
  actually in use. Instead, we now lookup the loaded libbe-image
  and get the entry_ref from its image_info.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43029 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2011-10-31 11:00:01 +00:00
parent 83b35411ed
commit cddcc2bea9

View File

@ -16,6 +16,7 @@
#include <syslog.h>
#include <AppFileInfo.h>
#include <Application.h>
#include <Autolock.h>
#include <Catalog.h>
#include <Collator.h>
@ -788,10 +789,32 @@ MutableLocaleRoster::GetSystemCatalog(BCatalogAddOn** catalog) const
{
if (!catalog)
return B_BAD_VALUE;
// get libbe entry_ref
// figure out libbe-image (shared object) by name
image_info info;
int32 cookie = 0;
bool found = false;
while (get_next_image_info(0, &cookie, &info) == B_OK) {
if (info.data < (void*)&be_app
&& (char*)info.data + info.data_size > (void*)&be_app) {
found = true;
break;
}
}
if (!found) {
log_team(LOG_DEBUG, "Unable to find libbe-image!");
return B_ERROR;
}
// load the catalog for libbe and return it to the app
entry_ref ref;
BEntry("/boot/system/lib/libbe.so").GetRef(&ref);
BEntry(info.name).GetRef(&ref);
*catalog = LoadCatalog(ref);
return B_OK;
}