Re: [gtk-list] Re: Gtk--: (resend) recent changes with GTK_OBJECT _CONSTRUCTED ??



On Sat, 13 Mar 1999 Robert_Gasch/PeopleSoft@peoplesoft.com wrote:

> Hi Tim,
> 
> thanks for your explanation of what GTK_OBJECT_CONSTRUCTED is
> actually used for ...
> 
> > i think the code to blame here is most probably the Gtk-- object construction
> > stuff, we need to know what widget is created wrongly here though.
> >
> > try to debug your program and in gdb you do:
> >
> > 1395      g_return_if_fail (GTK_IS_WIDGET (widget));
> > (gdb) n
> > 1396      g_return_if_fail (GTK_OBJECT_CONSTRUCTED (widget));
> > (gdb) n
> > > Gtk-CRITICAL **: file gtkwidget.c: line 1396 (gtk_widget_destroy): assertion
> > > `GTK_OBJECT_CONSTRUCTED (widget)' failed.
> > 1398      gtk_object_destroy ((GtkObject*) widget);
> > > 1399    }
> > (gdb) print *(GtkWidgetClass*)widget->object.klass
> 
> here it comes ... I should probably mention that this output is not the little
> test program I posted a few days ago but from a dialog used in terraform ... I
> found myself at work today (Saturday morning) and only had the terraform
> source available ...
> 
> Greetings & Thanks
> --> Robert
> 
> ------------------ gdb output ---------------------
> Breakpoint 1, gtk_widget_destroy (widget=0x829a8e8) at gtkwidget.c:1394
> 1394      g_return_if_fail (widget != NULL);
> (gdb)
> 1395      g_return_if_fail (GTK_IS_WIDGET (widget));
> (gdb)
> 1396      g_return_if_fail (GTK_OBJECT_CONSTRUCTED (widget));
> (gdb)
> 
> Gtk-CRITICAL **: file gtkwidget.c: line 1396 (gtk_widget_destroy): assertion
> `GTK_OBJECT_CONSTRUCTED (widget)' failed.
> 1399    }
> (gdb) print *(GtkWidgetClass*)widget->object.klass
> $1 = {parent_class = {type = 48917, signals = 0x0, nsignals = 0, n_args = 0,
>     construct_args = 0x0, set_arg = 0, get_arg = 0,
>     shutdown = 0x810a63c <gtk_widget_shutdown>,
>     destroy = 0x80a7d98 <Gtk_Object_Class::destroy_callback(_GtkObject *)>,
>     finalize = 0x80e7704 <gtk_range_finalize>}, activate_signal = 0,
>   set_scroll_adjustments_signal = 0,
>   show = 0x80afb9c <Gtk_Widget_Class::show_callback(_GtkWidget *)>,

uhm, i didn't consider that Gtk-- overloads virtually all class functions,
so print *(GtkWidgetClass*)widget->object.klass doesn't actually indicate
the correct class through the class function names. next time, 

(gdb) print gtk_type_name (widget->object.klass->type)

should do the trick anyways ;).

however, GtkWidget.finalize points to gtk_range_finalize, so the widget
in question is either a h/v scrollbar or a h/v scale, since all four of
them introduce a GTK_ARG_CONSTRUCT arg and are derived from GtkRange.

i don't know enough about Gtk-- to actually track this down/fix it, but
the code in question should probably look along the lines of:

Gtk_HScrollbar::Gtk_HScrollbar (void)
{
  this->object = gtk_object_new (GTK_TYPE_HSCROLLBAR, NULL);
}

Gtk_HScrollbar::Gtk_HScrollbar (GtkAdjustment *adjustment)
{
  this->object = gtk_object_new (GTK_TYPE_HSCROLLBAR,
                                 "adjustment", adjustment,
                                 NULL);
}

Gtk_HScrollbar::Gtk_HScrollbar (Gtk_Adjustment &gtkadjustment)
{
  this->object = gtk_object_new (GTK_TYPE_HSCROLLBAR,
                                 "adjustment", gtkadjustment.object,
                                 NULL);
}

but afaik, gtk_type_new() is what is really used inside Gtk--, in which case the
code should be:

Gtk_HScrollbar::Gtk_HScrollbar (void)
{
  this->object = gtk_type_new (GTK_TYPE_HSCROLLBAR);
  gtk_object_default_construct (object);
}

Gtk_HScrollbar::Gtk_HScrollbar (GtkAdjustment *adjustment)
{
  this->object = gtk_type_new (GTK_TYPE_HSCROLLBAR);
  gtk_range_set_adjustment (GTK_RANGE (object), adjustment);
  gtk_object_default_construct (object);
}

Gtk_HScrollbar::Gtk_HScrollbar (Gtk_Adjustment &gtkadjustment)
{
  this->object = gtk_type_new (GTK_TYPE_HSCROLLBAR);
  gtk_range_set_adjustment (GTK_RANGE (object), GTK_ADJUSTMENT (gtkadjustment.object));
  gtk_object_default_construct (object);
}

since calling gtk_object_default_construct() is mandatory after gtk_type_new().
(for objects that don't require default construction, the call is actually
pretty cheap).

---
ciaoTJ



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