Re: Custom widget headache



On Wed, May 31, 2006 at 05:06:50PM +0200, Daniel Haude wrote:

I changed over to the g_type system. Actually there wasn't much to change  
except in the
cw_area_get_type() function.

Alas, I still get exactly the same output.

Note I only read your code until I find a problem, so this
time it is:

static void cw_area_init(CwArea *area)
{
        static CwArea area_null;
ENTER
        *area = area_null;
        area->policy = GTK_UPDATE_CONTINUOUS;
EXIT
}

What the assignment *area = area_null is supposed to do?

What it does is overwriting class information, reference
count and object data (stuff set with
g_object_set_[q]data()) in area with zeroes, obviously
breaking its GObjectness.  And this was just for GObject
itself, GtkWidget (the direct parent) carefully initialized
its fields too, just to see them wiped out with
*area = area_null.

When you deal with GObjects you have to keep in mind there
is some data in the parent too.   You can define a method for
`assign by value' if your objects are capable of that, but
you cannot just memcopy the content of one object to
another.

and in the struct definitions (BTW I don't like to use leading underscores  
for the struct tags because they invade implementation namespace).

Well, prepare for more work with gtk-doc (for instance).
There are tools which understand the standard naming
convetion and do not understand yours.

The  
only important thing appears to me that the first member of the struct is  
the appropriate parent; in this case GtkWidget.

And that's the core of the problem.  GtkWidget is a *part*
of CwArea.

Yeti


--
Anonyms eat their boogers.



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