mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 22:20:24 +00:00
Fix some leaks. (#348108, Chris Wilson)
2006-12-22 Matthias Clasen <mclasen@redhat.com> * demos/gtk-demo/*.c: Fix some leaks. (#348108, Chris Wilson) 2
This commit is contained in:
parent
721c3bc101
commit
73614da57c
@ -1,3 +1,8 @@
|
|||||||
|
2006-12-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* demos/gtk-demo/*.c: Fix some leaks. (#348108, Chris
|
||||||
|
Wilson)
|
||||||
|
|
||||||
2006-12-22 Matthias Clasen <mclasen@redhat.com>
|
2006-12-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* *.c: Replace a lot of idle and timeout calls by
|
* *.c: Replace a lot of idle and timeout calls by
|
||||||
|
@ -467,6 +467,7 @@ do_appwindow (GtkWidget *do_widget)
|
|||||||
"stock-id", GTK_STOCK_OPEN,
|
"stock-id", GTK_STOCK_OPEN,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_action_group_add_action (action_group, open_action);
|
gtk_action_group_add_action (action_group, open_action);
|
||||||
|
g_object_unref (open_action);
|
||||||
gtk_action_group_add_actions (action_group,
|
gtk_action_group_add_actions (action_group,
|
||||||
entries, n_entries,
|
entries, n_entries,
|
||||||
window);
|
window);
|
||||||
@ -490,6 +491,7 @@ do_appwindow (GtkWidget *do_widget)
|
|||||||
gtk_ui_manager_insert_action_group (merge, action_group, 0);
|
gtk_ui_manager_insert_action_group (merge, action_group, 0);
|
||||||
gtk_window_add_accel_group (GTK_WINDOW (window),
|
gtk_window_add_accel_group (GTK_WINDOW (window),
|
||||||
gtk_ui_manager_get_accel_group (merge));
|
gtk_ui_manager_get_accel_group (merge));
|
||||||
|
g_object_unref (open_action);
|
||||||
|
|
||||||
if (!gtk_ui_manager_add_ui_from_string (merge, ui_info, -1, &error))
|
if (!gtk_ui_manager_add_ui_from_string (merge, ui_info, -1, &error))
|
||||||
{
|
{
|
||||||
|
@ -300,6 +300,8 @@ display_changed_cb (GtkTreeSelection *selection,
|
|||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
if (info->current_display)
|
||||||
|
g_object_unref (info->current_display);
|
||||||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||||
gtk_tree_model_get (model, &iter,
|
gtk_tree_model_get (model, &iter,
|
||||||
DISPLAY_COLUMN_DISPLAY, &info->current_display,
|
DISPLAY_COLUMN_DISPLAY, &info->current_display,
|
||||||
@ -320,6 +322,8 @@ screen_changed_cb (GtkTreeSelection *selection,
|
|||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
if (info->current_screen)
|
||||||
|
g_object_unref (info->current_screen);
|
||||||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||||
gtk_tree_model_get (model, &iter,
|
gtk_tree_model_get (model, &iter,
|
||||||
SCREEN_COLUMN_SCREEN, &info->current_screen,
|
SCREEN_COLUMN_SCREEN, &info->current_screen,
|
||||||
@ -562,6 +566,14 @@ destroy_info (ChangeDisplayInfo *info)
|
|||||||
g_slist_free (tmp_list);
|
g_slist_free (tmp_list);
|
||||||
|
|
||||||
g_object_unref (info->size_group);
|
g_object_unref (info->size_group);
|
||||||
|
g_object_unref (info->display_model);
|
||||||
|
g_object_unref (info->screen_model);
|
||||||
|
|
||||||
|
if (info->current_display)
|
||||||
|
g_object_unref (info->current_display);
|
||||||
|
if (info->current_screen)
|
||||||
|
g_object_unref (info->current_screen);
|
||||||
|
|
||||||
g_free (info);
|
g_free (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ create_stock_icon_store (void)
|
|||||||
PIXBUF_COL, pixbuf,
|
PIXBUF_COL, pixbuf,
|
||||||
TEXT_COL, label,
|
TEXT_COL, label,
|
||||||
-1);
|
-1);
|
||||||
|
g_object_unref (pixbuf);
|
||||||
g_free (label);
|
g_free (label);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -218,6 +218,16 @@ checkerboard_expose (GtkWidget *da,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
close_window (void)
|
||||||
|
{
|
||||||
|
window = NULL;
|
||||||
|
|
||||||
|
if (pixmap)
|
||||||
|
g_object_unref (pixmap);
|
||||||
|
pixmap = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
do_drawingarea (GtkWidget *do_widget)
|
do_drawingarea (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
@ -233,7 +243,7 @@ do_drawingarea (GtkWidget *do_widget)
|
|||||||
gtk_widget_get_screen (do_widget));
|
gtk_widget_get_screen (do_widget));
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
|
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
|
||||||
|
|
||||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
|
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
|
||||||
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||||
|
|
||||||
@ -309,14 +319,9 @@ do_drawingarea (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!GTK_WIDGET_VISIBLE (window))
|
if (!GTK_WIDGET_VISIBLE (window))
|
||||||
{
|
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
gtk_widget_destroy (window);
|
gtk_widget_destroy (window);
|
||||||
window = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
@ -243,6 +243,18 @@ home_clicked (GtkToolItem *item,
|
|||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void close_window(void)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (window);
|
||||||
|
window = NULL;
|
||||||
|
|
||||||
|
g_object_unref (file_pixbuf);
|
||||||
|
file_pixbuf = NULL;
|
||||||
|
|
||||||
|
g_object_unref (folder_pixbuf);
|
||||||
|
folder_pixbuf = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
do_iconview (GtkWidget *do_widget)
|
do_iconview (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
@ -258,7 +270,7 @@ do_iconview (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "GtkIconView demo");
|
gtk_window_set_title (GTK_WINDOW (window), "GtkIconView demo");
|
||||||
|
|
||||||
g_signal_connect (window, "destroy",
|
g_signal_connect (window, "destroy",
|
||||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
G_CALLBACK (close_window), NULL);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if (!load_pixbufs (&error))
|
if (!load_pixbufs (&error))
|
||||||
|
@ -782,6 +782,8 @@ create_tree (void)
|
|||||||
|
|
||||||
gtk_widget_grab_focus (tree_view);
|
gtk_widget_grab_focus (tree_view);
|
||||||
|
|
||||||
|
g_object_unref (model);
|
||||||
|
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -865,7 +867,7 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "GTK+ Code Demos");
|
gtk_window_set_title (GTK_WINDOW (window), "GTK+ Code Demos");
|
||||||
g_signal_connect (window, "destroy",
|
g_signal_connect_after (window, "destroy",
|
||||||
G_CALLBACK (gtk_main_quit), NULL);
|
G_CALLBACK (gtk_main_quit), NULL);
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 0);
|
hbox = gtk_hbox_new (FALSE, 0);
|
||||||
@ -881,13 +883,15 @@ main (int argc, char **argv)
|
|||||||
create_text (&info_buffer, FALSE),
|
create_text (&info_buffer, FALSE),
|
||||||
gtk_label_new_with_mnemonic ("_Info"));
|
gtk_label_new_with_mnemonic ("_Info"));
|
||||||
|
|
||||||
|
tag = gtk_text_buffer_create_tag (info_buffer, "title",
|
||||||
|
"font", "Sans 18",
|
||||||
|
NULL);
|
||||||
|
g_object_unref (info_buffer);
|
||||||
|
|
||||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
|
||||||
create_text (&source_buffer, TRUE),
|
create_text (&source_buffer, TRUE),
|
||||||
gtk_label_new_with_mnemonic ("_Source"));
|
gtk_label_new_with_mnemonic ("_Source"));
|
||||||
|
|
||||||
tag = gtk_text_buffer_create_tag (info_buffer, "title",
|
|
||||||
"font", "Sans 18",
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
tag = gtk_text_buffer_create_tag (source_buffer, "comment",
|
tag = gtk_text_buffer_create_tag (source_buffer, "comment",
|
||||||
"foreground", "DodgerBlue",
|
"foreground", "DodgerBlue",
|
||||||
@ -910,6 +914,7 @@ main (int argc, char **argv)
|
|||||||
"weight", PANGO_WEIGHT_BOLD,
|
"weight", PANGO_WEIGHT_BOLD,
|
||||||
"foreground", "DarkGoldenrod4",
|
"foreground", "DarkGoldenrod4",
|
||||||
NULL);
|
NULL);
|
||||||
|
g_object_unref (source_buffer);
|
||||||
|
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
|
@ -183,11 +183,13 @@ do_ui_manager (GtkWidget *do_widget)
|
|||||||
|
|
||||||
ui = gtk_ui_manager_new ();
|
ui = gtk_ui_manager_new ();
|
||||||
gtk_ui_manager_insert_action_group (ui, actions, 0);
|
gtk_ui_manager_insert_action_group (ui, actions, 0);
|
||||||
|
g_object_unref (actions);
|
||||||
gtk_window_add_accel_group (GTK_WINDOW (window),
|
gtk_window_add_accel_group (GTK_WINDOW (window),
|
||||||
gtk_ui_manager_get_accel_group (ui));
|
gtk_ui_manager_get_accel_group (ui));
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "UI Manager");
|
gtk_window_set_title (GTK_WINDOW (window), "UI Manager");
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
|
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
|
||||||
|
|
||||||
|
|
||||||
if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
|
if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
|
||||||
{
|
{
|
||||||
g_message ("building menus failed: %s", error->message);
|
g_message ("building menus failed: %s", error->message);
|
||||||
@ -223,6 +225,7 @@ do_ui_manager (GtkWidget *do_widget)
|
|||||||
gtk_widget_grab_default (button);
|
gtk_widget_grab_default (button);
|
||||||
|
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
|
g_object_unref (ui);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user