Mercurial > audlegacy
changeset 3833:f4f30254833b
better fix
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sun, 21 Oct 2007 08:46:58 -0500 |
parents | 194c6d2c25bc |
children | d087573f54fd c59c3df098c2 |
files | src/audacious/tuple.c |
diffstat | 1 files changed, 22 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/tuple.c Sun Oct 21 08:44:14 2007 -0500 +++ b/src/audacious/tuple.c Sun Oct 21 08:46:58 2007 -0500 @@ -145,6 +145,24 @@ return tuple; } +static gboolean +_tuple_associate_raw_string(Tuple *tuple, const gint nfield, const gchar *field, const gchar *string) +{ + TupleValue *value; + + TUPLE_LOCK_WRITE(); + if ((value = tuple_associate_data(tuple, nfield, field, TUPLE_STRING)) == NULL) + return FALSE; + + if (string == NULL) + value->value.string = NULL; + else + value->value.string = g_strdup(string); + + TUPLE_UNLOCK_WRITE(); + return TRUE; +} + Tuple * tuple_new_from_filename(const gchar *filename) { @@ -160,11 +178,11 @@ realfn = g_filename_from_uri(filename, NULL, NULL); scratch = g_path_get_basename(realfn ? realfn : filename); - tuple_associate_string(tuple, FIELD_FILE_NAME, NULL, scratch); + _tuple_associate_raw_string(tuple, FIELD_FILE_NAME, NULL, scratch); g_free(scratch); scratch = g_path_get_dirname(realfn ? realfn : filename); - tuple_associate_string(tuple, FIELD_FILE_PATH, NULL, scratch); + _tuple_associate_raw_string(tuple, FIELD_FILE_PATH, NULL, scratch); g_free(scratch); g_free(realfn); realfn = NULL; @@ -172,7 +190,7 @@ ext = strrchr(filename, '.'); if (ext != NULL) { ++ext; - tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, scratch); + _tuple_associate_raw_string(tuple, FIELD_FILE_EXT, NULL, scratch); } return tuple; @@ -254,7 +272,7 @@ if (string == NULL) value->value.string = NULL; else - value->value.string = g_strdup(string); + value->value.string = str_to_utf8(string); TUPLE_UNLOCK_WRITE(); return TRUE;