-----Original Message----- Date: Mon, 5 Jun 2006 15:47:36 +0200 Subject: Re: Strange Callback Behavior From: Tristan Van Berkom To: Peter Robinson
Peter Robinson wrote: [...] > > void open_data_file(gpointer callback_data, guint callback_action, GtkWidget *widget) { > GtkWidget *filew; [...] > > g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), > > "clicked", > > G_CALLBACK (data_file_ok_sel), > > of_context); > > (...) > > In the function data_file_ok_sel, however, for some reason the pointers > context->fs and context->label have different values, and the program dumps core when it tries to read constext->fs as a file selection widget: Seems you are using the somewhat obscure "swapped" flag for your "open_data_file" callback... which you are not doing for "data_file_ok_sel"... where is the prototype for "data_file_ok_sel" ? Cheers, -Tristan Thanks for the advice! I am not sure what you mean with the swap flag?! Do I need to use the g_signal_connect_swapped here? That function looks like this (simplified a bit) : static void data_file_ok_sel(GtkWidget *w, void *ptr ) { int len; struct openfile_context *context; context = (struct openfile_context *) ptr; g_print("In CALLBACK will print out ptr \n"); g_print("In CALLBACK pointer for callback is %p\n",context); g_print("In CALLBACK pointer for callback->fs is %p\n",context->fs); g_print("In CALLBACK pointer for callback->label is %p\n",context->label); g_print("In CALLBACK pointer is %p\n",GTK_FILE_SELECTION (context->fs)); const char *tmp = gtk_file_selection_get_filename (GTK_FILE_SELECTION (context->fs)); g_print("In CALLBACK 2 \n"); return; len = strlen(tmp); strncpy(datafile,tmp,len); datafile[len] = 0; gtk_widget_destroy(GTK_WIDGET(GTK_FILE_SELECTION (context->fs))); } gtk-app-devel-list@gnome.org _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list