Re: Abend in gdk_pixbuf_new_from_file



You are doing a gtk_widget_destroy, just before the pixbuf_new call. That
isn't required since you've anyway connected the clicked event with the
destroy function in your mytest function.

This may not be the solution, but it's possible the crash is actually
happening when the destroyed widget is being destroyed again.

-vc

----- Original Message ----- 
From: "Bryan Brown" <bbrown saltmine radix net>
To: <gtk-app-devel-list gnome org>
Sent: Thursday, February 26, 2004 6:45 PM
Subject: Abend in gdk_pixbuf_new_from_file


Hello,

My application (built using gtk 2.x under Redhat 9) sets up a file
selection dialog, waits for the user to select a file, then tries to read
the specified file into a pixbuf.

It's abending with a segmentation fault when it calls
gdk_pixbuf_new_from_file, the user having selected a standard
png-formatted picture file.

Here's a snippet of the relevant code:

===== begin code snip =====

GtkWidget *file_selector;
gchar     *filename;

[snip]

void
on_read_ok_button_clicked (GtkButton *button,
                           gpointer  user_data)
{
   gchar filename_local[BUFLEN] = "\0";
   GError *error;
   GdkPixbuf *pixbuf = NULL;

[snip]

   filename = (gchar *) gtk_file_selection_get_filename (
               GTK_FILE_SELECTION (file_selector));

[snip length checking]

   strcpy (filename_local, filename);
   gtk_widget_destroy (file_selector);

   pixbuf = gdk_pixbuf_new_from_file (filename_local,
                                      &error);


[snip]

void mytest ()

{

[snip]

   file_selector = gtk_file_selection_new ("Select an input file");

   g_signal_connect (
      GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
      "clicked",
      G_CALLBACK (on_read_ok_button_clicked),
      NULL);
   g_signal_connect_swapped (
      GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
      "clicked",
      G_CALLBACK (gtk_widget_destroy),
     (gpointer) file_selector);
   g_signal_connect_swapped (
      GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button),
      "clicked",
      G_CALLBACK (gtk_widget_destroy),
      (gpointer) file_selector);
   gtk_widget_show (file_selector);
}

===== end code snip =====

From debug printf statements I know that it's terminating in the call to
gdk_pixbuf_new_from_file(-).  The file it's attempting to load is a ".png"
formatted picture file built by gdk_pixbuf_save, and which displays fine
in other standalone utilities.

Any helpful ideas about what I'm doing wrong here?

Thanks,

Bryan


*---------------------------------------------------------------
* Bryan Brown      <*>              bbrown radix net
* http://www.radix.net/~bbrown
*---------------------------------------------------------------



_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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