Gtk+ memory management
- From: Andrey Maklakov <anmaklakov gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Gtk+ memory management
- Date: Mon, 11 Apr 2011 15:06:33 +0400
Hello.
Can you help me and answer some questions about memory management in Gtk+?
Look at next function:
1 void
2 tbar_makemenu (gint button)
3 {
4 const gchar *sid;
5 GList *list = NULL;
6
7 tbar_widget.menu[button] = gtk_menu_new ();
8 if (button == SID)
9 fdir_getext (filesdir, &list);
....
15 g_list_foreach (list, (GFunc) &list_menu_additem, &button);
16 g_list_free_full (list, &g_free);
17 gtk_widget_show_all (tbar_widget.menu[button]);
18 gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON
(tbar_widget.button[button]), tbar_widget.menu[button]);
19 }
My questions:
1) line 7 creates new GtkMenu, its child of GInitiallyUnowned, so
refcount = 1, but it is floating reference. True?
2) line 18 reference this menu with GtkMenuToolButton, so refcount =
1, and it is now not floating. True?
3) When I call this function 2nd time, and reference toolbutton with
new menu in line 18, what will happen? Old menu will get refcount = 0
and will be destroyed, or it is memory leak?
4) Will be destroyed menu items of old menu (which created in call of
g_list_foreach on line 15)?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]