Fix #8452 (app's crashing for non-existent system catalog)
* make the system catalog a BCatalog instead of a BCatalogAddOn*, such that using a non-existing system catalog won't crash but simply return the untranslated string instead * rename MutableLocaleRoster::GetSystemCatalog() to LoadSystemCatalog() and adjust it to use BCatalog::SetTo() in order to replace the data used by the given catalog * adjust all users of gSystemCatalog accordingly
This commit is contained in:
parent
cc52f0df3a
commit
eaa5e0936d
|
@ -46,7 +46,7 @@ public:
|
|||
// contain the language-name(s)
|
||||
status_t SetFilesystemTranslationPreferred(bool preferred);
|
||||
|
||||
status_t GetSystemCatalog(BCatalogAddOn** catalog) const;
|
||||
status_t LoadSystemCatalog(BCatalog* catalog) const;
|
||||
|
||||
BCatalogAddOn* LoadCatalog(const entry_ref& catalogOwner,
|
||||
const char* language = NULL,
|
||||
|
@ -109,7 +109,7 @@ struct RosterData {
|
|||
|
||||
BLocale fDefaultLocale;
|
||||
BTimeZone fDefaultTimeZone;
|
||||
|
||||
|
||||
bool fIsFilesystemTranslationPreferred;
|
||||
|
||||
bool fAreResourcesLoaded;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace BPrivate {
|
||||
|
||||
extern BCatalogAddOn* gSystemCatalog;
|
||||
extern BCatalog gSystemCatalog;
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
|
|
@ -90,9 +90,9 @@ BColorControl::_InitData(color_control_layout layout, float size,
|
|||
const char* red = B_TRANSLATE_MARK("Red:");
|
||||
const char* green = B_TRANSLATE_MARK("Green:");
|
||||
const char* blue = B_TRANSLATE_MARK("Blue:");
|
||||
red = gSystemCatalog->GetString(red, "ColorControl");
|
||||
green = gSystemCatalog->GetString(green, "ColorControl");
|
||||
blue = gSystemCatalog->GetString(blue, "ColorControl");
|
||||
red = gSystemCatalog.GetString(red, "ColorControl");
|
||||
green = gSystemCatalog.GetString(green, "ColorControl");
|
||||
blue = gSystemCatalog.GetString(blue, "ColorControl");
|
||||
|
||||
if (archive) {
|
||||
fRedText = (BTextControl*)FindView("_red");
|
||||
|
|
|
@ -43,7 +43,7 @@ using BPrivate::gSystemCatalog;
|
|||
|
||||
#undef B_TRANSLATE
|
||||
#define B_TRANSLATE(str) \
|
||||
gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "Dragger")
|
||||
gSystemCatalog.GetString(B_TRANSLATE_MARK(str), "Dragger")
|
||||
|
||||
const uint32 kMsgDragStarted = 'Drgs';
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ using BPrivate::gSystemCatalog;
|
|||
|
||||
#undef B_TRANSLATE
|
||||
#define B_TRANSLATE(str) \
|
||||
gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "Menu")
|
||||
gSystemCatalog.GetString(B_TRANSLATE_MARK(str), "Menu")
|
||||
|
||||
|
||||
using std::nothrow;
|
||||
|
|
|
@ -42,7 +42,7 @@ using BPrivate::gSystemCatalog;
|
|||
|
||||
#undef B_TRANSLATE
|
||||
#define B_TRANSLATE(str) \
|
||||
gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "PrintJob")
|
||||
gSystemCatalog.GetString(B_TRANSLATE_MARK(str), "PrintJob")
|
||||
|
||||
|
||||
/*! Summary of spool file:
|
||||
|
|
|
@ -65,7 +65,7 @@ using BPrivate::gSystemCatalog;
|
|||
|
||||
|
||||
#define TRANSLATE(str) \
|
||||
gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "TextView")
|
||||
gSystemCatalog.GetString(B_TRANSLATE_MARK(str), "TextView")
|
||||
|
||||
#undef TRACE
|
||||
#undef CALLED
|
||||
|
|
|
@ -26,7 +26,7 @@ using BPrivate::gSystemCatalog;
|
|||
|
||||
#undef B_TRANSLATE
|
||||
#define B_TRANSLATE(str) \
|
||||
gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "ZombieReplicantView")
|
||||
gSystemCatalog.GetString(B_TRANSLATE_MARK(str), "ZombieReplicantView")
|
||||
|
||||
|
||||
_BZombieReplicantView_::_BZombieReplicantView_(BRect frame, status_t error)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace BPrivate {
|
||||
|
||||
BCatalogAddOn* gSystemCatalog;
|
||||
BCatalog gSystemCatalog;
|
||||
|
||||
}
|
||||
|
||||
|
@ -129,5 +129,6 @@ __initialize_locale_kit()
|
|||
{
|
||||
SetupCatalogBasics();
|
||||
|
||||
MutableLocaleRoster::Default()->GetSystemCatalog(&BPrivate::gSystemCatalog);
|
||||
MutableLocaleRoster::Default()->LoadSystemCatalog(
|
||||
&BPrivate::gSystemCatalog);
|
||||
}
|
||||
|
|
|
@ -775,7 +775,7 @@ MutableLocaleRoster::SetFilesystemTranslationPreferred(bool preferred)
|
|||
|
||||
|
||||
status_t
|
||||
MutableLocaleRoster::GetSystemCatalog(BCatalogAddOn** catalog) const
|
||||
MutableLocaleRoster::LoadSystemCatalog(BCatalog* catalog) const
|
||||
{
|
||||
if (!catalog)
|
||||
return B_BAD_VALUE;
|
||||
|
@ -799,13 +799,13 @@ MutableLocaleRoster::GetSystemCatalog(BCatalogAddOn** catalog) const
|
|||
return B_ERROR;
|
||||
}
|
||||
|
||||
// load the catalog for libbe and return it to the app
|
||||
// load the catalog for libbe into the given catalog
|
||||
entry_ref ref;
|
||||
BEntry(info.name).GetRef(&ref);
|
||||
status_t status = BEntry(info.name).GetRef(&ref);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
*catalog = LoadCatalog(ref);
|
||||
|
||||
return B_OK;
|
||||
return catalog->SetTo(ref);
|
||||
}
|
||||
|
||||
|
||||
|
@ -859,8 +859,8 @@ MutableLocaleRoster::CreateCatalog(const char* type, const char* signature,
|
|||
* NULL is returned if no matching catalog could be found.
|
||||
*/
|
||||
BCatalogAddOn*
|
||||
MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner, const char* language,
|
||||
int32 fingerprint) const
|
||||
MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner,
|
||||
const char* language, int32 fingerprint) const
|
||||
{
|
||||
BAutolock lock(RosterData::Default()->fLock);
|
||||
if (!lock.IsLocked())
|
||||
|
|
|
@ -31,7 +31,7 @@ BAboutMenuItem::BAboutMenuItem()
|
|||
name = B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(info.ref.name);
|
||||
|
||||
const char* string = B_TRANSLATE_MARK("About %app%");
|
||||
string = gSystemCatalog->GetString(string, "AboutMenuItem");
|
||||
string = gSystemCatalog.GetString(string, "AboutMenuItem");
|
||||
|
||||
BString label = string;
|
||||
if (name != NULL)
|
||||
|
|
|
@ -32,8 +32,8 @@ BAboutWindow::BAboutWindow(const char *appName, int32 firstCopyrightYear,
|
|||
const char* copyright = B_TRANSLATE_MARK("Copyright " B_UTF8_COPYRIGHT
|
||||
" %years% Haiku, Inc.");
|
||||
const char* writtenBy = B_TRANSLATE_MARK("Written by:");
|
||||
copyright = gSystemCatalog->GetString(copyright, "AboutWindow");
|
||||
writtenBy = gSystemCatalog->GetString(writtenBy, "AboutWindow");
|
||||
copyright = gSystemCatalog.GetString(copyright, "AboutWindow");
|
||||
writtenBy = gSystemCatalog.GetString(writtenBy, "AboutWindow");
|
||||
|
||||
// Get current year
|
||||
time_t tp;
|
||||
|
@ -77,8 +77,8 @@ BAboutWindow::Show()
|
|||
{
|
||||
const char* aboutTitle = B_TRANSLATE_MARK("About" B_UTF8_ELLIPSIS);
|
||||
const char* closeLabel = B_TRANSLATE_MARK("Close");
|
||||
aboutTitle = gSystemCatalog->GetString(aboutTitle, "AboutWindow");
|
||||
closeLabel = gSystemCatalog->GetString(closeLabel, "AboutWindow");
|
||||
aboutTitle = gSystemCatalog.GetString(aboutTitle, "AboutWindow");
|
||||
closeLabel = gSystemCatalog.GetString(closeLabel, "AboutWindow");
|
||||
|
||||
BAlert *alert = new BAlert(aboutTitle, fText->String(), closeLabel);
|
||||
BTextView *view = alert->TextView();
|
||||
|
|
|
@ -25,33 +25,33 @@ string_for_size(double size, char* string, size_t stringSize)
|
|||
double kib = size / 1024.0;
|
||||
if (kib < 1.0) {
|
||||
const char* trKey = B_TRANSLATE_MARK("%d bytes");
|
||||
snprintf(string, stringSize, gSystemCatalog->GetString(trKey,
|
||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||
B_TRANSLATE_CONTEXT), (int)size);
|
||||
return string;
|
||||
}
|
||||
double mib = kib / 1024.0;
|
||||
if (mib < 1.0) {
|
||||
const char* trKey = B_TRANSLATE_MARK("%3.2f KiB");
|
||||
snprintf(string, stringSize, gSystemCatalog->GetString(trKey,
|
||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||
B_TRANSLATE_CONTEXT), kib);
|
||||
return string;
|
||||
}
|
||||
double gib = mib / 1024.0;
|
||||
if (gib < 1.0) {
|
||||
const char* trKey = B_TRANSLATE_MARK("%3.2f MiB");
|
||||
snprintf(string, stringSize, gSystemCatalog->GetString(trKey,
|
||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||
B_TRANSLATE_CONTEXT), mib);
|
||||
return string;
|
||||
}
|
||||
double tib = gib / 1024.0;
|
||||
if (tib < 1.0) {
|
||||
const char* trKey = B_TRANSLATE_MARK("%3.2f GiB");
|
||||
snprintf(string, stringSize, gSystemCatalog->GetString(trKey,
|
||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||
B_TRANSLATE_CONTEXT), gib);
|
||||
return string;
|
||||
}
|
||||
const char* trKey = B_TRANSLATE_MARK("%.2f TiB");
|
||||
snprintf(string, stringSize, gSystemCatalog->GetString(trKey,
|
||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||
B_TRANSLATE_CONTEXT), tib);
|
||||
return string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue