Re: GtkLayout, segfaulting with [hv]adjustment properties
- From: Owen Taylor <otaylor redhat com>
- To: jacob berkman <jacob ximian com>
- Cc: gtk-devel-list gnome org
- Subject: Re: GtkLayout, segfaulting with [hv]adjustment properties
- Date: 14 Nov 2001 16:03:23 -0500
jacob berkman <jacob ximian com> writes:
> i am getting a segfault in GtkLayout if i set the height/width
> properties before [hv]adjustment properties.
>
> in looking at it, i think it makes sense in gtk_layout_init() to call
> gtk_layout_set_adjustments(layout, NULL, NULL) rather than setting both
> of the adjustments to NULL.
>
> this is because typically, you are calling gtk_layout_new(), which does
> call gtk_layout_set_adjustments().
>
> i've attached some sample code wich seg faults with current cvs, but
> doesn't with the attached patch.
Hmm, I think it was already bad that
layout = gtk_layout_new (NULL, NULL);
gtk_container_add (scrolled_window, layout);
Generated and destroyed one set of adjustments. With your change,
it generates and destroys _two_ sets, which, I think, is just
too ugly to be acceptable.
One sketch of a solution would be to:
* If NULL adjustments are set during construction, don't create
adjustments
* Create default adjustments in a constructor() methods if
hadjustment, vadjustment are NULL.
* Make sure that all properties can be set prior to creating
the adjustments.
Regards,
Owen
> Index: gtklayout.c
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtklayout.c,v
> retrieving revision 1.44
> diff -u -r1.44 gtklayout.c
> --- gtklayout.c 2001/09/08 19:33:05 1.44
> +++ gtklayout.c 2001/11/14 18:12:37
> @@ -774,6 +774,8 @@
> layout->visibility = GDK_VISIBILITY_PARTIAL;
>
> layout->freeze_count = 0;
> +
> + gtk_layout_set_adjustments (layout, NULL, NULL);
> }
>
> /* Widget methods
>
> #include <gtk/gtk.h>
>
> int
> main (int argc, char *argv[])
> {
> GtkAdjustment *h, *v;
> GtkWidget *layout;
>
> gtk_init (&argc, &argv);
>
> h = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
> v = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
>
> g_object_new (GTK_TYPE_LAYOUT,
> "height", 100,
> "width", 100,
> "hadjustment", h,
> "vadjustment", v,
> NULL);
> }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]