Re: [gtk-list] gtkobject->ref_count ?




On Fri, 5 Feb 1999, Ketil Froyn wrote:
> Hi.
> I'm using gtk-1.1.12.
> I've made a program, and it used to work. Now, after a little more coding,
> i get
> Gtk-CRITICAL **: file gtkobject.c: line 1172 (gtk_object_unref): assertion
> `object->ref_count > 0' failed.
>

i.e. the refcount was already 0 when you tried to unref(), so probably you
unref() when you shouldn't.
 
> OK. What does this mean? I've been looking around, searching the docs,
> dejanews, and the source. gtkobject.c refers me to the file REFCOUNTING,
> which of course doesn't exist :)

gtk+/docs/refcounting.txt

> So i'm still trying to understand what i've done wrong. This happens when
> i'm trying to gtk_widget_unref() a drawing_area.
> 

Don't do that then. :-) Unless you called _ref() on it in the first place.
Widgets are destroyed when their parents are destroyed. They are also
destroyed if you remove them from a container. The only time you need to
worry about it is if you never put them in a container; also you might
want to gtk_widget_destroy() a toplevel window.

> Another question i was have: how i can register button_press_events on a
> drawing_area. It doesn't seem to work. I looked at the GIMP code and tried
> to connect a function to the "event" event, and then check if it was a
> button being pressed, and then checking if that button_event's->button==3
> (is that a right-click? looked like it from the source), but nothing
> happens.
> 

You must gtk_widget_set_events(), read the scribble example in the
tutorial.

> Yet another question: if i connect some functions to a statically
> defined widget, and then unref that widget and create a new one, will the
> connections still work? I'm assuming they won't until someone tells me
> otherwise :)
> 

No, connections are to particular widgets, not widget types. When the
widget is destroyed its connections disappear.

> BTW: are all the messages from this mailinglist stored somewhere so i can
> search through them before i ask here?
> 

On www.gtk.org.

Havoc




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