Re: Gnomification of Options dialog


Subject: Re: Gnomification of Options dialog
From: Joaquín Cuenca Abela (cuenca@ie2.u-psud.fr)
Date: Tue Apr 04 2000 - 13:28:42 CDT


John Tunison wrote:
>
> > It's also not quite right. When the dialog is closed (via cancel) in the
> > gnome version, I get:
> >
> > Gtk-CRITICAL **: file gtkwidget.c: line 4873 (gtk_widget_unref): assertion
> > `GTK_IS_WIDGET (widget)' failed.
>
> The five-line fix to this is to add gtk_widget_ref(buttonName)'s circa
> line 171 in ap_UnixGnomeDialog_Options.cpp. But could someone explain why
> they need to be explicitly ref'd?

Because you're adding these widgets to a hash table.

In short, imagine that you have the following code:

char *tmp = strdup ("Whatsoever");
char *tmp2 = tmp;
free(tmp);
printf ("%s\n", tmp2); /* and here, you're fucked */

To solve this problem, gtk (and all the modern languages) uses
refcounting. In the most basic gtk object (named GtkObject) there is a

guint ref_count;

And when you make a new object (say a GtkWidget), this field will be
initialized to 1. Now, if you have:

GtkWidget *tmp = gtk_wathsoever_new(...);

gtk_object_ref (tmp); /* Because we are going to add a second pointer to
this object */
GtkWidget *tmp2 = tmp;

gtk_object_unref (tmp);
whatsoever(..., tmp2, ...); /* and it works (TM) */
.
.
.
gtk_object_unref (tmp2); /* here, the refcounting of this object will
be 0 (if nobody has referenced it in the meantime), and thus the object
will be destroyed */

In your code, you've been binding your widgets to the main dialog widget
(a glade's influence? :) through a hash table (you're doing something
similar to tmp2 = tmp), and you have to increment the refcount of your
object. Even if you don't make the refcount, the same widget will be
unreferenced two times (the first unreference will destroy the widget,
and the second will try to unreference garbage, and here you will see
the gtk complain).

You have two option: Don't bind the widgets to the main dialog widget,
or reference them.

If you don't understand anything (for my bad english, or for my
explanation, e-mail me personally).

> Also, what can I do to make the Gnome fe a first-class citizen? I'd like
> to see RPMs of the Gnome build as well as the GTK build, for instance. If
> I start cleaning out all the warnings that happen when I make
> ABI_OPT_GNOME=1 will this magically happen? :)

I don't think that the gnome version has many more warnings that the
gtk+ version...
Paul et al. What do you about an "official" gnome version of Abiword.
I've seen that many people want to use it, and the "download & compile
the code" is an inconvenience. Do you think that there is something bad
with the gnome version? Do you have some misterious bug in the gnome
version that you want to see fixed before an "official" release?

> Thanks,

Cheers,

--
Joaquín Cuenca Abela
e-mail: cuenca@ie2.u-psud.fr



This archive was generated by hypermail 2b25 : Tue Apr 04 2000 - 13:28:48 CDT