GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 30, 2014 12:15 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: gdk_pixbuf_new_from_file(filename,&gerror);
PostPosted: Mon Oct 29, 2007 12:44 pm 
Offline

Joined: Mon Oct 29, 2007 12:39 pm
Posts: 4
i can load files into a widget with GTK_image_new_from_file, but can't get it into pixbuf with gdk_pixbuf_new_from_file


But it seems to have more trouble loading into pixbuf, when running:
test = gdk_pixbuf_new_from_file(filename,&gerror);
if(!test) {
printf("test file load failure, error message: %s\n", gerror->message);
exit(1);
}

But when running I get this:
[sbox-SDK_ARMEL: ~] > run-standalone.sh ./imageviewer/home/lpockett/.osso/current-gtk-key-theme:1: Unable to find include file: "keybindings.rc"
imageviewer[29855]: GLIB CRITICAL ** GdkPixbuf - gdk_pixbuf_new_from_file: assertion `error == NULL || *error == NULL' failed
test file load failure, error message: (null)

does anyone know what the problem is?
some guidence would be really appreaciated.
thanks in advance.

Sampson


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 4:14 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
What is "filename"? Is it an absolute or relative path. It looks like you are missing essential files, so you might want to try reinstalling GTK+ and its dependencies and see what happens after that. Try also reinstalling themes.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 30, 2007 9:55 am 
Offline

Joined: Mon Oct 29, 2007 12:39 pm
Posts: 4
the "filename" is a null terminated char array.
i get the same problem if i write
test = gdk_pixbuf_new_from_file("XYZ.jpg",&gerror);

the "keybindings.rc" is always there whenever i run a program, it's not dependant on when i come accross this error.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 30, 2007 2:02 pm 
Offline

Joined: Mon Oct 29, 2007 12:39 pm
Posts: 4
I found out how to fix it myself.
i guess i'll write the solution here in case anyone else comes accross the same problem.

the pointer needs to be initialized with a null value (i had previously initialized it but not assigned a value).

GError *gerror = 0;


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 21, 2007 11:42 am 
Offline
Familiar Face

Joined: Tue Nov 20, 2007 1:55 pm
Posts: 8
Hi,
I am also facing same problem...
GdkPixbuf *pixbuf = NULL;
GtkWidget *icon = NULL;

GError *gerror ;

pixbuf = gdk_pixbuf_new_from_file("Winter.jpeg",&gerror);
icon = gtk_image_new_from_pixbuf (pixbuf);
gdk_draw_pixbuf (widget->window, widget->style->white_gc, pixbuf, 0, 0, 60, 60, 100, 100, GDK_RGB_DITHER_NONE, 0, 0);
g_object_unref(pixbuf);

GLIB CRITICAL ** GdkPixbuf - gdk_pixbuf_new_from_file: assertion `error == NULL || *error == NULL' failed

then i made changes as you mentioned..

GError *gerror ;

but now it gives
GLIB CRITICAL ** GLib-GObject - g_object_unref: assertion `G_IS_OBJECT (object)' failed

so I am not seeing pixbuf.Please help me out..

regards,
sumit


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 21, 2007 11:47 am 
Offline
Familiar Face

Joined: Tue Nov 20, 2007 1:55 pm
Posts: 8
sorry..
i made
GError *gerror = 0 ;


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 21, 2007 4:29 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Yes, for those who are unclear, you must initialize your GError to NULL. When using GError, just do:

Code:
GError *error = NULL;


and you'll be fine. That's what the message "assertion `error == NULL || *error == NULL' failed" is telling you.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 3:55 am 
Offline
Familiar Face

Joined: Tue Nov 20, 2007 1:55 pm
Posts: 8
Thanks...
Now its working..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group