From 5dbb457c095b56fa85c269b40ecaa43a31a1f735 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 3 Aug 2010 08:48:34 +0000 Subject: [PATCH] * Allow ReadOnlyBootPrompt to change languages at runtime again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37862 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/readonlybootprompt/BootPromptWindow.cpp | 6 ++++-- src/kits/locale/Catalog.cpp | 8 +++----- src/kits/locale/CatalogStub.cpp | 8 ++++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/apps/readonlybootprompt/BootPromptWindow.cpp b/src/apps/readonlybootprompt/BootPromptWindow.cpp index 2f0611d9ef..c9ed28da25 100644 --- a/src/apps/readonlybootprompt/BootPromptWindow.cpp +++ b/src/apps/readonlybootprompt/BootPromptWindow.cpp @@ -177,13 +177,15 @@ BootPromptWindow::MessageReceived(BMessage* message) } } +namespace BPrivate { + void ForceUnloadCatalog(); +}; void BootPromptWindow::_InitCatalog(bool saveSettings) { // Initilialize the Locale Kit - // TODO : not possible with the current API ! - // sCatalogInitOnce = false; + BPrivate::ForceUnloadCatalog(); // Generate a settings file // TODO: This should not be necessary. diff --git a/src/kits/locale/Catalog.cpp b/src/kits/locale/Catalog.cpp index ed9aa50a9b..070f3538c5 100644 --- a/src/kits/locale/Catalog.cpp +++ b/src/kits/locale/Catalog.cpp @@ -100,11 +100,9 @@ BCatalog::GetData(uint32 id, BMessage *msg) status_t BCatalog::SetCatalog(const char* signature, uint32 fingerprint) { - // TODO: The previous fCatalog is leaked here. (The whole chain, it - // looks like.) We should take care that internal members are always - // properly maintained. - // No other method should touch fCatalog directly, either (constructor for - // example) + // This is not thread safe. It is used only in ReadOnlyBootPrompt and should + // not do harm there, but not sure what to do about it… + delete fCatalog; fCatalog = mutable_locale_roster->LoadCatalog(signature, NULL, fingerprint); return B_OK; diff --git a/src/kits/locale/CatalogStub.cpp b/src/kits/locale/CatalogStub.cpp index 0646e9fdad..03a576fba2 100644 --- a/src/kits/locale/CatalogStub.cpp +++ b/src/kits/locale/CatalogStub.cpp @@ -24,3 +24,11 @@ BLocaleRoster::GetCatalog() return _GetCatalog(&sCatalog, &sCatalogInitOnce); } + +namespace BPrivate{ + void ForceUnloadCatalog() + { + sCatalogInitOnce = false; + } +} +