destroying an unparented widget

There's one thing I've never quite understood: the correct
mechanism for destroying a gtk widget that is never parented or

The context is that I'm creating a temporary widget with
gtk_label_new(), just for the purpose of getting hold of its
PangoContext so I can figure something out about the font in use
(whether it supports the UTF-8 minus sign, 0x2212). Once I've got
that info I'm using gtk_widget_destroy on the label. And valgrind
is showing me a leak, which I take to mean that I haven't managed
to destroy the widget. If I try using g_object_unref() instead I
get an error message from GTK saying I can't do that on an object
which has only a floating reference.

Would the correct sequence be

label = gtk_label_new("");
/* do pango stuff */

? And if so, is there an equivalent in GLib < 2.10? Thanks.

Allin Cottrell
Department of Economics
Wake Forest University

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