GNOME Bugzilla – Bug 324667
gdk_pixbuf_loader_write doesn't signal until 1k is written.
Last modified: 2010-07-10 04:04:46 UTC
Please describe the problem: When using the gdk_pixbuf_loader widget, I noticed that certain images are not loaded. I've found that it seems to occur when the image size is less than 1k. Steps to reproduce: //Run this this with filename_of_small_image pointing to a file //with a jpg under 1024k GdkPixbufLoader *loader; GdkPixbuf* pixbuf; char* data; int len=0; FILE* icon_file=fopen(filename_of_small_image,"r"); while(!feof(icon_file)) data[len++]=fgetc(icon_file); loader=gdk_pixbuf_loader_new(); gdk_pixbuf_loader_write(loader,data,len,&err); //No area_prepared or area_updated signals get emitted. pixbuf=gdk_pixbuf_loader_get_pixbuf(loader); //pixbuf will be null. Actual results: See comments. Expected results: I expect some signals to be emitted, and pixbuf to be non-null. Does this happen every time? Yes, whenever the file is under 1024 bytes. Other information: Workaround: pad the image with trailing 0's pushing it up to 1024 bytes in size.
What gtk version ? I believe this has been fixed in one of the last versions
I was thinking of bug 318589
Oh, I see now what is wrong. You need to call gdk_pixbuf_loader_close() when you have fed all data to it, then it will work.
Ok, that fixed it. It's a slightly "non-traditional" way of using a close function, which is why I didn't do it that way. Moving things around fixes the code. Are there any caveats with this, with threads, for example? Couldn't the pixbuf be destroyed between the call to _write and _get_pixbuf?
Sorry, I meant between _close and _get_pixbuf.