Re: Problem with GdkPixbuf
- From: "richard boaz" <riboaz xs4all nl>
- To: "dashikugua 126 com" <dashikugua 126 com>
- Cc: gtk-list <gtk-list gnome org>
- Subject: Re: Problem with GdkPixbuf
- Date: Thu, 5 Jul 2007 09:34:54 +0200
And to answer your question:
The documentation for gtk_image_get_pixbuf() states:
The caller of this function does not own a reference to the returned pixbuf.
I.e., you cannot free a resource that's not yours, so the request fails. The error message is unfortunate, it's not terribly accurate.
The code rewrite suggestion is the way to go.
richard
On 7/5/07, dashikugua 126 com <dashikugua 126 com> wrote:
Hi all:
I'm using the Gtkimage and GdkPixbuf to show picture and each time I run the program I get the following error:
GLib-Gobject-CRITICAL ** : g_object_unref : assertion `G_IS_OBJECT(object)` failed
I'm running GTK 2.6.4 and Glib 2.6.4 on a Debian woody.Here is the code which reproduces the problem:
#include <gtk/gtk.h>
int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *image;
GdkPixbuf *pix1;
GdkPixbuf *pix2;
gtk_init(&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
image = gtk_image_new_from_file ("1.png");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
gtk_container_add (GTK_CONTAINER (window), image);
pix1=gtk_image_get_pixbuf(GTK_IMAGE(image));
pix2=gdk_pixbuf_scale_simple(pix1,320,160,GDK_INTERP_BILINEAR);
gtk_image_set_from_pixbuf(GTK_IMAGE(image),pix2);
g_object_unref(pix1);
g_object_unref(pix2);
gtk_widget_show (image);
gtk_widget_show (window);
gtk_main ();
return(0);
}
I have no idea how to resolve the problem.Any help will be most appreciated.Thanks.
百 万 玩 家 同 玩 的 乐 园,人 气 爆 发 的 梦 幻 西 游
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]