changeset 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 25a3c1b7d090
children 732cd2afae10
files gui/mplayer/gtk/fs.c gui/mplayer/gtk/pl.c
diffstat 2 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/gui/mplayer/gtk/fs.c	Fri Jan 21 15:24:18 2011 +0000
+++ b/gui/mplayer/gtk/fs.c	Fri Jan 21 15:33:12 2011 +0000
@@ -161,6 +161,7 @@
  char * dir, * utf8dir;
  dir = get_current_dir_name();
  utf8dir = g_filename_to_utf8( dir, -1, NULL, NULL, NULL );
+ if ( !utf8dir ) utf8dir = g_strdup( dir );
  free( dir );
  return utf8dir;
 }
@@ -184,7 +185,7 @@
   gchar *filename, *str[2];
   filename = g_filename_to_utf8(fname, -1, NULL, NULL, NULL);
   str[0] = NULL;
-  str[1] = filename;
+  str[1] = filename ? filename : fname;
   pos = gtk_clist_append(GTK_CLIST(list), str);
   gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask);
   g_free(filename);
@@ -430,7 +431,7 @@
 
  str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
  dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
- if ( chdir( dirname ) != -1 ) CheckDir( fsFNameList );
+ if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList );
  g_free( dirname );
 }
 
@@ -442,7 +443,7 @@
 
  str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
  dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
- if ( chdir( dirname ) != -1 ) CheckDir( fsFNameList );
+ if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList );
  g_free( dirname );
 }
 
@@ -524,7 +525,7 @@
  gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile );
  g_free( fsSelectedFileUtf8 );
  fsSelectedFileUtf8 = g_filename_from_utf8( fsSelectedFile, -1, NULL, NULL, NULL );
- fsSelectedFile = fsSelectedFileUtf8;
+ if ( fsSelectedFileUtf8 ) fsSelectedFile = fsSelectedFileUtf8;
  if( bevent && bevent->type == GDK_BUTTON_PRESS )  gtk_button_released( GTK_BUTTON( fsOk ) );
 }
 
--- 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++;