diff gui/mplayer/gtk/pl.c @ 32723:5310794ef052

Check conversion to and from UTF-8. (If G_FILENAME_ENCODING isn't properly set, the conversion may fail. In this case we go with the original names.)
author ib
date Fri, 21 Jan 2011 15:33:12 +0000
parents 6ff3cc81d602
children dc8779e0e9cc
line wrap: on
line diff
--- a/gui/mplayer/gtk/pl.c	Fri Jan 21 15:24:18 2011 +0000
+++ b/gui/mplayer/gtk/pl.c	Fri Jan 21 15:33:12 2011 +0000
@@ -181,8 +181,8 @@
      char * text[1][3]; text[0][2]="";
      name = g_filename_to_utf8( next->name, -1, NULL, NULL, NULL );
      path = g_filename_to_utf8( next->path, -1, NULL, NULL, NULL );
-     text[0][0]=name;
-     text[0][1]=path;
+     text[0][0]=name ? name : next->name;
+     text[0][1]=path ? path : next->path;
      gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
      g_free( path );
      g_free( name );
@@ -242,7 +242,9 @@
 	  gtk_clist_get_text( GTK_CLIST( CLSelected ),i,0,&text[0] );
 	  gtk_clist_get_text( GTK_CLIST( CLSelected ),i,1,&text[1] );
 	  item->name=g_filename_from_utf8( text[0], -1, NULL, NULL, NULL );
+	  if ( !item->name ) item->name = strdup( text[0] );
 	  item->path=g_filename_from_utf8( text[1], -1, NULL, NULL, NULL );
+	  if ( !item->path ) item->path = strdup( text[1] );
 	  gtkSet( gtkAddPlItem,0,(void*)item );
 	 }
 	if ( plCurrent )
@@ -301,7 +303,7 @@
 	      CLListSelected[NrOfSelected - 1]=0;
 	      gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,(char **)&itext );
 	      cpath=g_filename_to_utf8( current_path, -1, NULL, NULL, NULL );
-	      text[0][0]=itext[0][0]; text[0][1]=cpath;
+	      text[0][0]=itext[0][0]; text[0][1]=cpath ? cpath : current_path;
 	      gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
 	      g_free( cpath );
 	     }
@@ -373,7 +375,7 @@
 	{
 	 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=0; DirNode->path=strdup( path );
 	 subdir=check_for_subdir( path );
-	 node=gtk_ctree_insert_node( ctree,parent_node,NULL,&name,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
+	 node=gtk_ctree_insert_node( ctree,parent_node,NULL,(name ? &name : &text ),4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
 	 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL );
 	 if ( subdir ) node=gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE );
 	}
@@ -408,7 +410,7 @@
 	 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) )
 	  {
 	   name=g_filename_to_utf8( dirent->d_name, -1, NULL, NULL, NULL );
-	   text[0][0]=name;
+	   text[0][0]=name ? name : dirent->d_name;
 	   gtk_clist_append( GTK_CLIST( CLFiles ), text[0] );
 	   g_free( name );
 	   NrOfEntrys++;