Commit 86f66ed9 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Workaround for crash in ReadDirectory when called from the comboURL text box....

Workaround for crash in ReadDirectory when called from the comboURL text box. For now it is mandatory to prefix filepaths on local disk with "file://" when typing it in the comboURL box.
parent 884742bd
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* callbacks.c : Callbacks for the Familiar Linux Gtk+ plugin. * callbacks.c : Callbacks for the Familiar Linux Gtk+ plugin.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: callbacks.c,v 1.14 2002/12/15 22:45:35 jpsaman Exp $ * $Id: callbacks.c,v 1.15 2002/12/16 21:48:17 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -95,8 +95,6 @@ static void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url ) ...@@ -95,8 +95,6 @@ static void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
intf_thread_t *p_intf = GtkGetIntf( widget ); intf_thread_t *p_intf = GtkGetIntf( widget );
playlist_t *p_playlist; playlist_t *p_playlist;
g_print( "%s\n",psz_url );
// Add p_url to playlist .... but how ? // Add p_url to playlist .... but how ?
p_playlist = (playlist_t *) p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
...@@ -125,15 +123,12 @@ void ReadDirectory( GtkCList *clist, char *psz_dir ) ...@@ -125,15 +123,12 @@ void ReadDirectory( GtkCList *clist, char *psz_dir )
struct dirent **namelist; struct dirent **namelist;
int n,status; int n,status;
if ( p_intf->p_sys->b_filelist_update == 0) msg_Dbg(p_intf, "changing to dir %s\n", psz_dir);
{
msg_Err(p_intf, "changing to dir %s\n", psz_dir);
p_intf->p_sys->b_filelist_update = 1;
if (psz_dir) if (psz_dir)
{ {
status = chdir(psz_dir); status = chdir(psz_dir);
if (status<0) if (status<0)
msg_Err( p_intf, "file is not a directory" ); msg_Err( p_intf, "permision denied" );
} }
n = scandir(".", &namelist, 0, alphasort); n = scandir(".", &namelist, 0, alphasort);
...@@ -151,17 +146,13 @@ void ReadDirectory( GtkCList *clist, char *psz_dir ) ...@@ -151,17 +146,13 @@ void ReadDirectory( GtkCList *clist, char *psz_dir )
/* This is a list of strings. */ /* This is a list of strings. */
ppsz_text[0] = namelist[i]->d_name; ppsz_text[0] = namelist[i]->d_name;
ppsz_text[1] = get_file_perm(namelist[i]->d_name); ppsz_text[1] = get_file_perm(namelist[i]->d_name);
if (strcmp(ppsz_text[1],"") == 0) // msg_Dbg(p_intf, "(%d) file: %s permission: %s", i, ppsz_text[0], ppsz_text[1] );
msg_Err( p_intf->p_sys->p_input, "File system error unknown filetype encountered.");
gtk_clist_insert( clist, i, ppsz_text ); gtk_clist_insert( clist, i, ppsz_text );
free(namelist[i]); free(namelist[i]);
} }
gtk_clist_thaw( clist ); gtk_clist_thaw( clist );
free(namelist); free(namelist);
} }
}
p_intf->p_sys->b_filelist_update = 0;
} }
static char* get_file_perm(const char *path) static char* get_file_perm(const char *path)
...@@ -394,7 +385,7 @@ void ...@@ -394,7 +385,7 @@ void
on_comboURL_entry_changed (GtkEditable *editable, on_comboURL_entry_changed (GtkEditable *editable,
gpointer user_data) gpointer user_data)
{ {
intf_thread_t * p_intf = GtkGetIntf( GTK_WIDGET( editable ) ); // intf_thread_t * p_intf = GtkGetIntf( GTK_WIDGET(editable) );
gchar * psz_url; gchar * psz_url;
struct stat st; struct stat st;
...@@ -415,9 +406,22 @@ on_comboURL_entry_changed (GtkEditable *editable, ...@@ -415,9 +406,22 @@ on_comboURL_entry_changed (GtkEditable *editable,
} }
else if (lstat((char*)psz_url, &st)==0) else if (lstat((char*)psz_url, &st)==0)
{ {
#if 0
// This piece of code crashes in ReadDirectory at gtk_clist_insert()
// I cannot figure out why. So for now it is mandatory to use the
// file:// syntax for opening a file on a known location.
// The strange thing is it only crashes for names beginning with "/" or "."
// The combobox is means as a URL box, so having "file://" in front
// is not that strange ;-)
if (S_ISDIR(st.st_mode)) if (S_ISDIR(st.st_mode))
{
if (!p_intf->p_sys->p_clist)
msg_Err(p_intf, "p_clist pointer invalid!!" );
ReadDirectory(p_intf->p_sys->p_clist, psz_url); ReadDirectory(p_intf->p_sys->p_clist, psz_url);
else if( (S_ISLNK(st.st_mode)) || (S_ISCHR(st.st_mode)) || }
else
#endif
if( (S_ISLNK(st.st_mode)) || (S_ISCHR(st.st_mode)) ||
(S_ISBLK(st.st_mode)) || (S_ISFIFO(st.st_mode))|| (S_ISBLK(st.st_mode)) || (S_ISFIFO(st.st_mode))||
(S_ISSOCK(st.st_mode))|| (S_ISREG(st.st_mode)) ) (S_ISSOCK(st.st_mode))|| (S_ISREG(st.st_mode)) )
{ {
...@@ -426,6 +430,7 @@ on_comboURL_entry_changed (GtkEditable *editable, ...@@ -426,6 +430,7 @@ on_comboURL_entry_changed (GtkEditable *editable,
} }
} }
void void
on_clistmedia_click_column (GtkCList *clist, on_clistmedia_click_column (GtkCList *clist,
gint column, gint column,
...@@ -457,7 +462,7 @@ on_clistmedia_select_row (GtkCList *clist, ...@@ -457,7 +462,7 @@ on_clistmedia_select_row (GtkCList *clist,
GdkEvent *event, GdkEvent *event,
gpointer user_data) gpointer user_data)
{ {
intf_thread_t * p_intf = GtkGetIntf( GTK_WIDGET( clist ) ); intf_thread_t * p_intf = GtkGetIntf( GTK_WIDGET(clist) );
gchar *text[2]; gchar *text[2];
gint ret; gint ret;
struct stat st; struct stat st;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* familiar.c : familiar plugin for vlc * familiar.c : familiar plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: familiar.c,v 1.15 2002/12/15 22:45:35 jpsaman Exp $ * $Id: familiar.c,v 1.16 2002/12/16 21:48:17 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -86,20 +86,19 @@ static int Open( vlc_object_t *p_this ) ...@@ -86,20 +86,19 @@ static int Open( vlc_object_t *p_this )
return VLC_ENOMEM; return VLC_ENOMEM;
} }
#ifdef NEED_GTK_MAIN //#ifdef NEED_GTK_MAIN
p_intf->p_sys->p_gtk_main = module_Need( p_this, "gtk_main", "gtk" ); p_intf->p_sys->p_gtk_main = module_Need( p_this, "gtk_main", "gtk" );
if( p_intf->p_sys->p_gtk_main == NULL ) if( p_intf->p_sys->p_gtk_main == NULL )
{ {
free( p_intf->p_sys ); free( p_intf->p_sys );
return VLC_ENOMOD; return VLC_ENOMOD;
} }
#endif //#endif
/* Initialize Gtk+ thread */ /* Initialize Gtk+ thread */
p_intf->p_sys->p_input = NULL; p_intf->p_sys->p_input = NULL;
p_intf->p_sys->b_autoplayfile = 1; p_intf->p_sys->b_autoplayfile = 1;
p_intf->p_sys->b_filelist_update = 0;
p_intf->pf_run = Run; p_intf->pf_run = Run;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -117,9 +116,9 @@ static void Close( vlc_object_t *p_this ) ...@@ -117,9 +116,9 @@ static void Close( vlc_object_t *p_this )
vlc_object_release( p_intf->p_sys->p_input ); vlc_object_release( p_intf->p_sys->p_input );
} }
#ifdef NEED_GTK_MAIN //#ifdef NEED_GTK_MAIN
module_Unneed( p_intf, p_intf->p_sys->p_gtk_main ); module_Unneed( p_intf, p_intf->p_sys->p_gtk_main );
#endif //#endif
/* Destroy structure */ /* Destroy structure */
free( p_intf->p_sys ); free( p_intf->p_sys );
...@@ -162,7 +161,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -162,7 +161,7 @@ static void Run( intf_thread_t *p_intf )
// FIXME: magic path // FIXME: magic path
add_pixmap_directory("share"); add_pixmap_directory("share");
add_pixmap_directory("/usr/share/videolan"); add_pixmap_directory("/usr/share/vlc");
p_intf->p_sys->p_window = create_familiar(); p_intf->p_sys->p_window = create_familiar();
if (p_intf->p_sys->p_window == NULL) if (p_intf->p_sys->p_window == NULL)
...@@ -196,7 +195,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -196,7 +195,7 @@ static void Run( intf_thread_t *p_intf )
gtk_widget_show( p_intf->p_sys->p_window ); gtk_widget_show( p_intf->p_sys->p_window );
ReadDirectory(p_intf->p_sys->p_clist, "/mnt"); ReadDirectory(p_intf->p_sys->p_clist, "/mnt");
#ifdef NEED_GTK_MAIN //#ifdef NEED_GTK_MAIN
/* Sleep to avoid using all CPU - since some interfaces need to /* Sleep to avoid using all CPU - since some interfaces need to
* access keyboard events, a 100ms delay is a good compromise */ * access keyboard events, a 100ms delay is a good compromise */
while( !p_intf->b_die ) while( !p_intf->b_die )
...@@ -205,15 +204,15 @@ static void Run( intf_thread_t *p_intf ) ...@@ -205,15 +204,15 @@ static void Run( intf_thread_t *p_intf )
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
gdk_threads_enter(); gdk_threads_enter();
} }
#endif //#endif
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) ); gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
#ifdef NEED_GTK_MAIN //#ifdef NEED_GTK_MAIN
gdk_threads_leave(); gdk_threads_leave();
#else //#else
gtk_main_quit(); gtk_main_quit();
#endif //#endif
} }
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment