After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 109334 - Pango::AttrList problem
Pango::AttrList problem
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.2
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2003-03-27 16:16 UTC by ec142
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description ec142 2003-03-27 16:16:59 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
Comment 1 Murray Cumming 2003-03-27 16:28:51 UTC
Thanks. In future, please attach example code rather than pasting it.
Comment 2 Martin Schulze 2003-03-27 23:06:09 UTC
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.)
Comment 3 Murray Cumming 2003-03-28 07:54:36 UTC
Well done Martin.
Comment 4 Murray Cumming 2003-04-01 17:47:09 UTC
Please reopen this bug if it's still a problem.