[Haiku-commits] r33375 - in haiku/trunk/src/preferences: appearance bluetooth

Oliver Tappe zooey at hirschkaefer.de
Sat Oct 3 20:00:22 CEST 2009


Hi Michael,

On 2009-10-01 at 00:09:28 [+0200], Michael Weirauch <dev at m-phasis.de> wrote:
> 2009/9/30 PulkoMandy <pulkomandy at gmail.com>:
> > What other solution do you suggest, in order not to leak the be_catalog in
> > any case and be able to use it as needed ?
> > GSoC is finished now, I'd be happy if other people started to improve the
> > code of the locale kit. I'm sure you can help :)
> 
> In expectation that might be utterly wrong: :)
> 
> Index: src/kits/locale/Locale.cpp
> ===================================================================
> --- src/kits/locale/Locale.cpp  (revision 33370)
> +++ src/kits/locale/Locale.cpp  (working copy)
> @@ -24,6 +24,8 @@
> 
>  BLocale::~BLocale()
>  {
> +       delete be_app_catalog;
> +       delete be_catalog;
>  }

This will most likely crash or at least do a double delete, as be_catalog and 
be_app_catalog point to the same object in the usual case (they're only 
different for an add-on).

> @@ -46,9 +48,7 @@
> 
>  status_t
>  BLocale::GetAppCatalog(BCatalog *catalog) {
> -       if (!catalog)
> -               return B_BAD_VALUE;
>         if (be_catalog)
>                 debugger( "GetAppCatalog() has been called while
> be_catalog != NULL");
> -       return BCatalog::GetAppCatalog(catalog);
> +       return BCatalog::GetAppCatalog(catalog ? catalog : new BCatalog);
>  }
> 
> 
> Allows for be_locale->GetAppCatalog(NULL); and makes sure the be_[app_]catalog
> are being freed when my printfs() didn't fool me.
> 
> Whenever the locale changes, call GetAppCatalog again and work with
> be_[app_]catalog?

We could provide BLocaleApplication as a locale-aware BApplication that 
automatically fetches the app's catalog and deletes it upon destruction. On top 
of that, the BLocaleApplication could help with implementing the handling of a 
language change.

What do you think?

cheers,
	Oliver



More information about the Haiku-commits mailing list