comparison src/aosd/aosd_trigger.c @ 766:53f63f43663f trunk

[svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
author giacomo
date Thu, 01 Mar 2007 18:22:51 -0800
parents 40fb4189fa88
children 9794a5487524
comparison
equal deleted inserted replaced
765:2430c9773fa7 766:53f63f43663f
162 Playlist *active = playlist_get_active(); 162 Playlist *active = playlist_get_active();
163 gint pos = playlist_get_position(active); 163 gint pos = playlist_get_position(active);
164 title = playlist_get_songtitle(active, pos); 164 title = playlist_get_songtitle(active, pos);
165 } 165 }
166 gchar *utf8_title = str_to_utf8( title ); 166 gchar *utf8_title = str_to_utf8( title );
167 gchar *utf8_title_markup = g_markup_printf_escaped( 167 if ( g_utf8_validate( utf8_title , -1 , NULL ) == TRUE )
168 "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title ); 168 {
169 aosd_display( utf8_title_markup , global_config->osd , FALSE ); 169 gchar *utf8_title_markup = g_markup_printf_escaped(
170 g_free( utf8_title_markup ); 170 "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
171 aosd_display( utf8_title_markup , global_config->osd , FALSE );
172 g_free( utf8_title_markup );
173 }
171 g_free( utf8_title ); 174 g_free( utf8_title );
172 g_free( title ); 175 g_free( title );
173 } 176 }
174 return; 177 return;
175 } 178 }
226 { 229 {
227 if ( ( pl_entry->title != NULL ) && ( strcmp(pl_entry->title,prevs->title) ) ) 230 if ( ( pl_entry->title != NULL ) && ( strcmp(pl_entry->title,prevs->title) ) )
228 { 231 {
229 /* string formatting is done here a.t.m. - TODO - improve this area */ 232 /* string formatting is done here a.t.m. - TODO - improve this area */
230 gchar *utf8_title = str_to_utf8( pl_entry->title ); 233 gchar *utf8_title = str_to_utf8( pl_entry->title );
231 gchar *utf8_title_markup = g_markup_printf_escaped( 234 if ( g_utf8_validate( utf8_title , -1 , NULL ) == TRUE )
232 "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title ); 235 {
233 aosd_display( utf8_title_markup , global_config->osd , FALSE ); 236 gchar *utf8_title_markup = g_markup_printf_escaped(
234 g_free( utf8_title_markup ); 237 "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
238 aosd_display( utf8_title_markup , global_config->osd , FALSE );
239 g_free( utf8_title_markup );
240 }
235 g_free( utf8_title ); 241 g_free( utf8_title );
236 g_free( prevs->title ); 242 g_free( prevs->title );
237 prevs->title = g_strdup(pl_entry->title); 243 prevs->title = g_strdup(pl_entry->title);
238 } 244 }
239 } 245 }