[gtkmm] BUG: Gdk::PixbufLoader must outlive its Gtk::Image
- From: Christof Petig <christof petig-baender de>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: [gtkmm] BUG: Gdk::PixbufLoader must outlive its Gtk::Image
- Date: Mon, 15 Jul 2002 16:15:40 +0200
Dear Gtkmm developers,
While embedding compressed pictures (.png/.jpg) within Gtkmm2 programs I
came across the following bug:
If the Gdk::PixbufLoader is destroyed after a Gtk::Image is created from
the pixbuf the program segfaults. Shouldn't it ref the Pixbuf?
Simple test program attached
g++ -o tmp -DCRASH tmp.cc `pkg-config --cflags --libs gtkmm-2.0`
if you remove -DCRASH all works well.
Yours
Christof (glade-- maintainer)
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gdkmm/pixbufloader.h>
#include <gtkmm/image.h>
class window1 : public Gtk::Window
{
#ifndef CRASH
Glib::RefPtr<Gdk::PixbufLoader> _image1_loader;
#endif
public:
window1();
};
static const unsigned char whiteball_png_data[] =
{ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,
0,0,0,14,0,0,0,14,8,0,0,0,1,77,36,66,
155,0,0,0,2,116,82,78,83,0,191,45,77,99,37,0,
0,0,158,73,68,65,84,120,156,101,204,161,14,194,48,24,
69,225,211,166,201,138,106,144,211,168,201,74,50,67,120,4,
222,1,199,227,96,121,4,38,145,251,49,179,72,166,72,101,
113,235,212,134,1,4,48,131,186,230,220,79,9,154,70,9,
250,9,242,138,98,56,131,18,208,217,234,166,109,85,41,1,
37,100,150,30,141,91,250,174,193,208,239,186,180,70,9,0,
24,112,140,15,52,206,123,50,52,158,246,186,199,80,19,234,
28,195,252,16,216,78,253,111,153,238,56,91,64,106,109,255,
209,60,64,28,46,169,196,0,97,54,164,24,239,97,40,49,
48,158,236,152,186,20,217,124,169,236,24,201,139,197,191,252,
6,228,146,55,128,102,61,156,175,0,0,0,0,73,69,78,
68,174,66,96,130,
};
window1::window1(
) : Gtk::Window(Gtk::WINDOW_TOPLEVEL)
#ifndef CRASH
, _image1_loader(Gdk::PixbufLoader::create())
#endif
{ GError *err=0;
#ifdef CRASH
Glib::RefPtr<Gdk::PixbufLoader> _image1_loader=Gdk::PixbufLoader::create();
#endif
_image1_loader->write(whiteball_png_data, sizeof whiteball_png_data, err);
_image1_loader->close();
Gtk::Image *image1 = manage(new class Gtk::Image(_image1_loader->get_pixbuf()));
add(*image1);
image1->show();
show();
}
int main(int argc, char **argv)
{ Gtk::Main m(&argc, &argv);
class window1 *w=new class window1();
m.run();
delete w;
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]