Re: Crashing with widgets as class members



If you include a widget in a class where that widget's instantiation would occur before Gtk has been initialized, you will see this behavior. You need to include your classes as pointers and not instantiate them until you're actually ready for them to come into existance.

Bob Caryl

John C. Spray wrote:

Hello,

I'm having crashes where I have widgets which created as members of a
class, rather than creating them with Gtk::manage(new Gtk::whatever).
This used to work okay, the code hasn't changed but the build options
may have done.

Am I doing something illegal when I do:

class MyClass {
	public:
	Gtk::ComboBoxText mycombo_;
}

Rather than

class MyClass {
	public:
	Gtk::ComboBoxText *mycombo_;
	void build();
}

void MyClass::build() {
	mycombo_ = Gtk::manage(new Gtk::ComboBoxText);
}

Because the latter seems to work where the first kind of thing gives
results like:

#0  IA__g_logv (log_domain=Variable "log_domain" is not available.
) at gmessages.c:503
#1  0x003f5963 in IA__g_log (log_domain=0x3ba01e "glibmm",
   log_level=G_LOG_LEVEL_ERROR,
   format=0x419d98 "file %s: line %d (%s): assertion failed: (%s)")
   at gmessages.c:517
#2  0x003f59b8 in IA__g_assert_warning (log_domain=0x3ba01e "glibmm",
   file=0x3baab7 "objectbase.cc", line=77,
   pretty_function=0x3ca180 "void
Glib::ObjectBase::initialize(GObject*)",
   expression=0x3baaa2 "gobject_ == castitem") at gmessages.c:552
#3  0x003afc1f in Glib::ObjectBase::initialize (this=Variable "this" is
not available.
) at objectbase.cc:77
#4  0x003af5ee in Object (this=0x9cf4070, __vtt_parm=0x898545c,
   construct_params= 0xbf8fa460) at object.cc:232
#5  0x0063585b in Object (this=0x9cf4038, __vtt_parm=0x8985458,
   construct_params= 0xbf8fa460) at object.cc:35
#6  0x00681f6b in Widget (this=0x9cf4038, __vtt_parm=0x8985454,
   construct_params= 0xbf8fa460) at widget.cc:5041
#7  0x006067d8 in Container (this=0x9cf4038, __vtt_parm=0x8985450,
   construct_params= 0xbf8fa460) at container.cc:674
#8  0x005ee074 in Bin (this=0x9cf4038, __vtt_parm=0x898544c,
   construct_params= 0xbf8fa460) at bin.cc:195
#9  0x00603d4b in ComboBox (this=0x9cf4038, __vtt_parm=0x8985448,
   construct_params= 0xbf8fa460) at combobox.cc:200
#10 0x006058ff in ComboBoxEntry (this=0x9cf4038, __vtt_parm=0x8985444)
   at comboboxentry.cc:141
#11 0x0069656f in ComboBoxEntryText (this=0x9cf4038) at
comboboxentrytext.cc:33
#12 0x086bd5da in lyx::frontend::GBibtex::GBibtex ()

Where GBibtex is a class with a member of type Gtk::ComboBoxEntry.

Regards,
John

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


begin:vcard
fn:Robert Caryl
n:Caryl;Robert
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758;USA
email;internet:bob fis-cal com
title:Senior Software Design Engineer
tel;work:356-772-8920 X108
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]