Segfault with gtk_file_selection_new()



Hello All,
    When my program opens a file selector for the second time it seg faults 
in the middle of the gtk_file_selection_new() function. Is this a bug or a
programming error? A small snippit is posted below.

=== Cut ===
/*******************************************************************/
/* void OpenFile(gchar *FileName)                                  */
/* Opens the file [FileName], gets its format and opens it's window*/
void OpenFile(gchar *FileName)
{
    FileNode *Node;

    Node=CreateFileNode();
    Node->Name=strdup(FileName);
    if(!(Node->Handle=afOpenFile(Node->Name, "r", NULL)))
    {
 RemoveFileNode(Node);
 fputs("Not an audio file\n",stderr);
 return;
    }
    GetSampleInfo(Node);
    GetSampleData(Node);
    DrawFileWindow(Node);

}
/*******************************************************************/


/*******************************************************************/
/* void FileSelectOK(GtkWidget *w, GtkFileSelection *FileSelection)*/
/* FileSelect callback, Opens the selected file                    */
void FileSelectOK(GtkWidget *w, GtkFileSelection *FileSelection)
{
    gchar *FileName =
strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSelection)));
    if(FileName[strlen(FileName)-1]!='/')
    {
 gtk_widget_destroy(GTK_WIDGET(FileSelection));
 OpenFile(FileName);
    }
}
/*******************************************************************/


/*******************************************************************/
/* void FileOpen(GtkWidget *w, gchar *Title)                       */
/* Opens a fileselector to open a file                             */
void FileOpen(GtkWidget *w, gchar *Title)
{
    GtkWidget *FileSelector;


    FileSelector=gtk_file_selection_new("Open");
    gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(FileSelector)->ok_butt 
on), "clicked", (GtkSignalFunc) FileSelectOK, FileSelector);
    gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(FileSelector)-> 
cancel_button), "clicked", (GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT(FileSelector));

    gtk_widget_show(FileSelector);
}
/*******************************************************************/
===Cut===
















Martin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]