toggletoolbutton label leak?
- From: Balazs Scheidler <bazsi balabit hu>
- To: gtkmm-list gnome org
- Subject: toggletoolbutton label leak?
- Date: Sat, 30 Dec 2006 00:54:44 +0100
Hi,
Sorry If I'm missing something obvious, but I'm a newbie in both Gtkmm
and Gtk+.
I'm trying to generate toolbar entries dynamically, basically I want a
nautilus like history bar, using Gtk::ToggleToolButtons to represent
nodes in my tree.
Thus whenever a node is selected I'm updating the toolbar with the
following code:
Gtk::ToolItem *
MainWindow::new_history_button(const std::string &text) const
{
Gtk::ToggleToolButton *b;
Gtk::Label *label;
label = Gtk::manage(new Gtk::Label());
label->set_use_markup(true);
label->set_label(text);
label->show();
b = Gtk::manage(new Gtk::ToggleToolButton());
b->set_label_widget(*label);
b->set_homogeneous(false);
b->show();
return b;
}
void
MainWindow::update_history_bar(const Glib::RefPtr<Component> &last_shown)
{
Glib::RefPtr<Component> p;
Gtk::ToolItem *item;
// free previous toolbar buttons
while (history_bar->get_n_items() > 0)
{
item = history_bar->get_nth_item(0);
if (item)
{
history_bar->remove(*item);
delete item;
}
}
// build new buttons
p = last_shown;
while (p->get_parent())
{
item = new_history_button(p->name);
static_cast<Gtk::ToggleToolButton *>(item)->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::on_history_button_pressed));
history_bar->prepend(*item);
p = p->get_parent();
}
}
My problem is that, according to valgrind, new_history_button() function
leaks all Gtk::Label instances regardless if I'm using Gtk::manage() on
instance creation or not.
The funny part is that the Gtk::ToggleToolButton instances are not
leaked. So as it seems Gtk::ToggleToolButton fails to free the label
attached using set_label_widget()
What am I missing here?
--
Bazsi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]