Add xdg_init-free versions of some functions and use them internally, so

2006-07-20  Matthias Clasen  <mclasen@redhat.com>

	* xdgmimemagic.c:
	* xdgmime.c:
	* xdgmime.h: Add xdg_init-free versions of some
	functions and use them internally, so that we don't
	reload caches and clobber data structures in the
	middle of an operation.  Patch by Joe Shaw,
	bugs.freedesktop.org #6824
This commit is contained in:
Matthias Clasen 2006-07-20 04:14:59 +00:00 committed by Matthias Clasen
parent ed1f9073ff
commit 81c0660f19
4 changed files with 58 additions and 20 deletions

View File

@ -1,3 +1,13 @@
2006-07-20 Matthias Clasen <mclasen@redhat.com>
* xdgmimemagic.c:
* xdgmime.c:
* xdgmime.h: Add xdg_init-free versions of some
functions and use them internally, so that we don't
reload caches and clobber data structures in the
middle of an operation. Patch by Joe Shaw,
bugs.freedesktop.org #6824
2006-07-19 Matthias Clasen <mclasen@redhat.com>
* xdgmimeglob.c (_xdg_glob_hash_node_lookup_file_name):

View File

@ -602,12 +602,10 @@ xdg_mime_get_max_buffer_extents (void)
}
const char *
xdg_mime_unalias_mime_type (const char *mime_type)
_xdg_mime_unalias_mime_type (const char *mime_type)
{
const char *lookup;
xdg_mime_init ();
if (_caches)
return _xdg_mime_cache_unalias_mime_type (mime_type);
@ -617,16 +615,22 @@ xdg_mime_unalias_mime_type (const char *mime_type)
return mime_type;
}
const char *
xdg_mime_unalias_mime_type (const char *mime_type)
{
xdg_mime_init ();
return _xdg_mime_unalias_mime_type (mime_type);
}
int
xdg_mime_mime_type_equal (const char *mime_a,
const char *mime_b)
_xdg_mime_mime_type_equal (const char *mime_a,
const char *mime_b)
{
const char *unalias_a, *unalias_b;
xdg_mime_init ();
unalias_a = xdg_mime_unalias_mime_type (mime_a);
unalias_b = xdg_mime_unalias_mime_type (mime_b);
unalias_a = _xdg_mime_unalias_mime_type (mime_a);
unalias_b = _xdg_mime_unalias_mime_type (mime_b);
if (strcmp (unalias_a, unalias_b) == 0)
return 1;
@ -634,6 +638,15 @@ xdg_mime_mime_type_equal (const char *mime_a,
return 0;
}
int
xdg_mime_mime_type_equal (const char *mime_a,
const char *mime_b)
{
xdg_mime_init ();
return _xdg_mime_mime_type_equal (mime_a, mime_b);
}
int
xdg_mime_media_type_equal (const char *mime_a,
const char *mime_b)
@ -668,19 +681,17 @@ xdg_mime_is_super_type (const char *mime)
#endif
int
xdg_mime_mime_type_subclass (const char *mime,
const char *base)
_xdg_mime_mime_type_subclass (const char *mime,
const char *base)
{
const char *umime, *ubase;
const char **parents;
xdg_mime_init ();
if (_caches)
return _xdg_mime_cache_mime_type_subclass (mime, base);
umime = xdg_mime_unalias_mime_type (mime);
ubase = xdg_mime_unalias_mime_type (base);
umime = _xdg_mime_unalias_mime_type (mime);
ubase = _xdg_mime_unalias_mime_type (base);
if (strcmp (umime, ubase) == 0)
return 1;
@ -703,13 +714,22 @@ xdg_mime_mime_type_subclass (const char *mime,
parents = _xdg_mime_parent_list_lookup (parent_list, umime);
for (; parents && *parents; parents++)
{
if (xdg_mime_mime_type_subclass (*parents, ubase))
if (_xdg_mime_mime_type_subclass (*parents, ubase))
return 1;
}
return 0;
}
int
xdg_mime_mime_type_subclass (const char *mime,
const char *base)
{
xdg_mime_init ();
return _xdg_mime_mime_type_subclass (mime, base);
}
char **
xdg_mime_list_mime_parents (const char *mime)
{
@ -741,7 +761,7 @@ xdg_mime_get_mime_parents (const char *mime)
xdg_mime_init ();
umime = xdg_mime_unalias_mime_type (mime);
umime = _xdg_mime_unalias_mime_type (mime);
return _xdg_mime_parent_list_lookup (parent_list, umime);
}

View File

@ -96,8 +96,16 @@ int xdg_mime_register_reload_callback (XdgMimeCallback callback,
XdgMimeDestroy destroy);
void xdg_mime_remove_callback (int callback_id);
/* Private versions of functions that don't call xdg_mime_init () */
int _xdg_mime_mime_type_equal (const char *mime_a,
const char *mime_b);
int _xdg_mime_media_type_equal (const char *mime_a,
const char *mime_b);
int _xdg_mime_mime_type_subclass (const char *mime,
const char *base);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __XDG_MIME_H__ */

View File

@ -664,7 +664,7 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
{
if (_xdg_mime_magic_match_compare_to_data (match, data, len))
{
if ((mime_type == NULL) || (xdg_mime_mime_type_subclass (match->mime_type, mime_type))) {
if ((mime_type == NULL) || (_xdg_mime_mime_type_subclass (match->mime_type, mime_type))) {
mime_type = match->mime_type;
}
}
@ -673,7 +673,7 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
for (n = 0; n < n_mime_types; n++)
{
if (mime_types[n] &&
xdg_mime_mime_type_equal (mime_types[n], match->mime_type))
_xdg_mime_mime_type_equal (mime_types[n], match->mime_type))
mime_types[n] = NULL;
}
}