mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-25 11:42:10 +01:00
Clean up l10n threading stuff
Remove the explicit thread initialisation functions for g_get_charset(), g_get_filename_charsets() and g_get_language_names(). Add a lock around one remaining case of access to libcharset (the other 2 cases already have the lock). Do a proper g_once_init_enter() style initialisation for the GLib gettext functions. https://bugzilla.gnome.org/show_bug.cgi?id=658683
This commit is contained in:
parent
bceaf3a719
commit
f1494c156d
@ -1425,16 +1425,6 @@ get_filename_charset (const gchar **filename_charset)
|
||||
return is_utf8;
|
||||
}
|
||||
|
||||
/* This is called from g_thread_init(). It's used to
|
||||
* initialize some static data in a threadsafe way.
|
||||
*/
|
||||
void
|
||||
_g_convert_thread_init (void)
|
||||
{
|
||||
const gchar **dummy;
|
||||
(void) g_get_filename_charsets (&dummy);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_filename_to_utf8:
|
||||
* @opsysstring: a string in the encoding for filenames
|
||||
|
@ -957,10 +957,6 @@ g_thread_init_glib (void)
|
||||
|
||||
/* accomplish log system initialization to enable messaging */
|
||||
_g_messages_thread_init_nomessage ();
|
||||
|
||||
/* we may run full-fledged initializers from here */
|
||||
_g_convert_thread_init ();
|
||||
_g_utils_thread_init ();
|
||||
}
|
||||
|
||||
/* The following sections implement: GOnce, GStaticMutex, GStaticRecMutex,
|
||||
|
@ -53,8 +53,6 @@ G_GNUC_INTERNAL void _g_slice_thread_init_nomessage (void);
|
||||
G_GNUC_INTERNAL void _g_messages_thread_init_nomessage (void);
|
||||
|
||||
/* full fledged initializers */
|
||||
G_GNUC_INTERNAL void _g_convert_thread_init (void);
|
||||
G_GNUC_INTERNAL void _g_utils_thread_init (void);
|
||||
G_GNUC_INTERNAL void _g_thread_impl_init (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -597,7 +597,9 @@ g_get_charset (const char **charset)
|
||||
g_static_private_set (&cache_private, cache, charset_cache_free);
|
||||
}
|
||||
|
||||
G_LOCK (aliases);
|
||||
raw = _g_locale_charset_raw ();
|
||||
G_UNLOCK (aliases);
|
||||
|
||||
if (!(cache->raw && strcmp (cache->raw, raw) == 0))
|
||||
{
|
||||
|
@ -3648,15 +3648,6 @@ g_get_codeset (void)
|
||||
return g_strdup (charset);
|
||||
}
|
||||
|
||||
/* This is called from g_thread_init(). It's used to
|
||||
* initialize some static data in a threadsafe way.
|
||||
*/
|
||||
void
|
||||
_g_utils_thread_init (void)
|
||||
{
|
||||
g_get_language_names ();
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
/**
|
||||
@ -3707,11 +3698,13 @@ _glib_get_locale_dir (void)
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
static void
|
||||
ensure_gettext_initialized(void)
|
||||
ensure_gettext_initialized (void)
|
||||
{
|
||||
static gboolean _glib_gettext_initialized = FALSE;
|
||||
static gsize initialised;
|
||||
|
||||
if (!_glib_gettext_initialized)
|
||||
g_thread_init_glib ();
|
||||
|
||||
if (g_once_init_enter (&initialised))
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
gchar *tmp = _glib_get_locale_dir ();
|
||||
@ -3723,7 +3716,7 @@ ensure_gettext_initialized(void)
|
||||
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
# endif
|
||||
_glib_gettext_initialized = TRUE;
|
||||
g_once_init_leave (&initialised, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user