GNOME Bugzilla – Bug 109334
Pango::AttrList problem
Last modified: 2004-12-22 21:47:04 UTC
I get segmentation fault from the following program. If I comment out the line labelAttributes.insert( attr ); in the constructor, the program works. I have tryed with both Gtk::Fixed and Gtk::Frame. If the label is displayed in the constructor the problem disappears. The problem seems not to be related to the use of polimorfism on the widget, as I have tryed to replace Gtk::Widget *widget with Gtk::Label *widget, and I get segmentation fault as well. #include <gtkmm/main.h> #include <gtkmm/window.h> #include <gtkmm/fixed.h> #include <gtkmm/frame.h> #include <gtkmm/label.h> class Screen : public Gtk::Window{ protected: Gtk::Frame screenContainer; Gtk::Widget *widget; //Gtk::Label *widget; public: Screen(); ~Screen(); void refresh(); }; Screen::Screen() { set_default_size(600,600); Pango::Attribute attr = Pango::Attribute::create_attr_size(30000); Pango::AttrList labelAttributes; labelAttributes.insert( attr ); Gtk::Label *label = manage( new Gtk::Label("4") ); label->set_attributes(labelAttributes); widget = label; //screenContainer.put( *widget, 300, 300 ); add( screenContainer ); show_all(); } Screen::~Screen(){ if( widget != NULL ){ delete widget; } } void Screen::refresh() { //screenContainer.put(*widget,200,200); screenContainer.add(*widget); show_all(); queue_draw(); return; } int main (int argc, char *argv[]) { Gtk::Main kit(argc, argv); Screen screen; screen.refresh(); kit.run(screen); return 0; } This is what I get in gdb: Program received signal SIGSEGV, Segmentation fault. 0x40590c0e in pango_attribute_copy (attr=0x8081248) at pango- attributes.c:8686 result = attr->klass->copy (attr); Current language: auto; currently c Regards, Enrico Costanza
Thanks. In future, please attach example code rather than pasting it.
I'm afraid this is related to a forgotten TODO of mine in pango/src/attrlist.hg: // TODO: copy or reference? <- please elaborate! We have to hand code AttrList::insert, AttrList::insert_before, AttrList::change. They have to pass a copy of the attribute parameter into the c functions so that the GList can take over ownership. Enrico, please check with latest cvs whether the problem still remains. (I just committed the necessary changes to both gtkmm2 and gtkmm.)
Well done Martin.
Please reopen this bug if it's still a problem.