diff options
50 files changed, 237 insertions, 291 deletions
diff --git a/demos/gtk-demo/application_demo.c b/demos/gtk-demo/application_demo.c index 8f36568464..087ea3ff8f 100644 --- a/demos/gtk-demo/application_demo.c +++ b/demos/gtk-demo/application_demo.c @@ -31,12 +31,7 @@ on_name_vanished (GDBusConnection *connection, if (!name_seen) return; - if (placeholder) - { - gtk_widget_destroy (placeholder); - g_object_unref (placeholder); - placeholder = NULL; - } + g_clear_object (&placeholder); } #ifdef G_OS_WIN32 diff --git a/demos/gtk-demo/constraints.c b/demos/gtk-demo/constraints.c index e8934031d5..b6c5df0bd3 100644 --- a/demos/gtk-demo/constraints.c +++ b/demos/gtk-demo/constraints.c @@ -25,9 +25,9 @@ simple_grid_dispose (GObject *object) { SimpleGrid *self = SIMPLE_GRID (object); - g_clear_pointer (&self->button1, gtk_widget_destroy); - g_clear_pointer (&self->button2, gtk_widget_destroy); - g_clear_pointer (&self->button3, gtk_widget_destroy); + g_clear_pointer (&self->button1, gtk_widget_unparent); + g_clear_pointer (&self->button2, gtk_widget_unparent); + g_clear_pointer (&self->button3, gtk_widget_unparent); G_OBJECT_CLASS (simple_grid_parent_class)->dispose (object); } diff --git a/demos/gtk-demo/constraints2.c b/demos/gtk-demo/constraints2.c index e5dd879198..2a9477e048 100644 --- a/demos/gtk-demo/constraints2.c +++ b/demos/gtk-demo/constraints2.c @@ -26,9 +26,9 @@ interactive_grid_dispose (GObject *object) { InteractiveGrid *self = INTERACTIVE_GRID (object); - g_clear_pointer (&self->button1, gtk_widget_destroy); - g_clear_pointer (&self->button2, gtk_widget_destroy); - g_clear_pointer (&self->button3, gtk_widget_destroy); + g_clear_pointer (&self->button1, gtk_widget_unparent); + g_clear_pointer (&self->button2, gtk_widget_unparent); + g_clear_pointer (&self->button3, gtk_widget_unparent); G_OBJECT_CLASS (interactive_grid_parent_class)->dispose (object); } diff --git a/demos/gtk-demo/constraints3.c b/demos/gtk-demo/constraints3.c index 86e753b3a6..0edc5b8ebd 100644 --- a/demos/gtk-demo/constraints3.c +++ b/demos/gtk-demo/constraints3.c @@ -24,9 +24,9 @@ vfl_grid_dispose (GObject *object) { VflGrid *self = VFL_GRID (object); - g_clear_pointer (&self->button1, gtk_widget_destroy); - g_clear_pointer (&self->button2, gtk_widget_destroy); - g_clear_pointer (&self->button3, gtk_widget_destroy); + g_clear_pointer (&self->button1, gtk_widget_unparent); + g_clear_pointer (&self->button2, gtk_widget_unparent); + g_clear_pointer (&self->button3, gtk_widget_unparent); G_OBJECT_CLASS (vfl_grid_parent_class)->dispose (object); } diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c index 9c2454f058..06addd854d 100644 --- a/demos/gtk-demo/dnd.c +++ b/demos/gtk-demo/dnd.c @@ -138,7 +138,7 @@ edit_label_done (GtkWidget *entry, gpointer data) gtk_label_set_text (GTK_LABEL (label), gtk_editable_get_text (GTK_EDITABLE (entry))); gtk_widget_show (label); - gtk_widget_destroy (entry); + gtk_container_remove (GTK_CONTAINER (canvas), entry); } static void @@ -170,7 +170,9 @@ edit_cb (GtkWidget *button, GtkWidget *child) static void delete_cb (GtkWidget *button, GtkWidget *child) { - gtk_widget_destroy (child); + GtkWidget *canvas = gtk_widget_get_parent (child); + + gtk_container_remove (GTK_CONTAINER (canvas), child); gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER))); } @@ -419,7 +421,6 @@ do_dnd (GtkWidget *do_widget) { GtkWidget *sw; GtkWidget *canvas; - GtkWidget *widget; GtkWidget *box, *box2, *box3; const char *colors[] = { "red", "green", "blue", "magenta", "orange", "gray", "black", "yellow", @@ -430,9 +431,8 @@ do_dnd (GtkWidget *do_widget) int i; int x, y; - widget = gtk_color_button_new (); - gtk_widget_destroy (widget); - + g_type_ensure (GTK_TYPE_COLOR_BUTTON); + window = gtk_window_new (); gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget)); diff --git a/demos/gtk-demo/font_features.c b/demos/gtk-demo/font_features.c index 0a09dc05bf..818164d5f3 100644 --- a/demos/gtk-demo/font_features.c +++ b/demos/gtk-demo/font_features.c @@ -1025,7 +1025,7 @@ denorm_coord (hb_ot_var_axis_info_t *axis, int coord) static void update_font_variations (void) { - GtkWidget *child, *next; + GtkWidget *child; PangoFont *pango_font = NULL; hb_font_t *hb_font; hb_face_t *hb_face; @@ -1037,12 +1037,8 @@ update_font_variations (void) int i; child = gtk_widget_get_first_child (variations_grid); - while (child != NULL) - { - next = gtk_widget_get_next_sibling (child); - gtk_widget_destroy (child); - child = next; - } + while ((child = gtk_widget_get_first_child (variations_grid))) + gtk_container_remove (GTK_CONTAINER (variations_grid), child); instance_combo = NULL; diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index f9aaae6df4..94c201a043 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -221,11 +221,18 @@ gtk_container_init (GtkContainer *container) } static void +gtk_container_remove_cb (GtkWidget *child, + GtkContainer *container) +{ + gtk_container_remove (container, child); +} + +static void gtk_container_dispose (GObject *object) { GtkContainer *container = GTK_CONTAINER (object); - gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL); + gtk_container_foreach (container, (GtkCallback) gtk_container_remove_cb, container); G_OBJECT_CLASS (gtk_container_parent_class)->dispose (object); } diff --git a/gtk/gtkemojicompletion.c b/gtk/gtkemojicompletion.c index 810d6c1729..9f5fe235c6 100644 --- a/gtk/gtkemojicompletion.c +++ b/gtk/gtkemojicompletion.c @@ -548,7 +548,7 @@ populate_completion (GtkEmojiCompletion *completion, const char *text, guint offset) { - GList *children, *l; + GtkWidget *child; guint n_matches; guint n_added; GVariantIter iter; @@ -562,10 +562,8 @@ populate_completion (GtkEmojiCompletion *completion, } completion->offset = offset; - children = gtk_container_get_children (GTK_CONTAINER (completion->list)); - for (l = children; l; l = l->next) - gtk_widget_destroy (GTK_WIDGET (l->data)); - g_list_free (children); + while ((child = gtk_widget_get_first_child (completion->list))) + gtk_container_remove (GTK_CONTAINER (completion->list), child); completion->active = NULL; diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c index 8d58dc253d..f87a974c89 100644 --- a/gtk/gtkfilechoosernativeportal.c +++ b/gtk/gtkfilechoosernativeportal.c @@ -75,7 +75,7 @@ filechooser_portal_data_free (FilechooserPortalData *data) if (data->grab_widget) { gtk_grab_remove (data->grab_widget); - gtk_widget_destroy (data->grab_widget); + g_object_unref (data->grab_widget); } g_clear_object (&data->self); @@ -397,7 +397,7 @@ window_handle_exported (GtkWindow *window, if (data->modal) { - data->grab_widget = gtk_label_new (""); + data->grab_widget = g_object_ref_sink (gtk_label_new ("")); gtk_grab_add (GTK_WIDGET (data->grab_widget)); } diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 0a694d5d18..4c61e180f8 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -2360,7 +2360,7 @@ save_widgets_destroy (GtkFileChooserWidget *impl) if (impl->save_widgets == NULL) return; - gtk_widget_destroy (impl->save_widgets); + gtk_container_remove (GTK_CONTAINER (impl->box), impl->save_widgets); impl->save_widgets = NULL; impl->save_widgets_table = NULL; impl->location_entry = NULL; @@ -3091,7 +3091,7 @@ gtk_file_chooser_widget_dispose (GObject *object) cancel_all_operations (impl); g_clear_pointer (&impl->rename_file_popover, gtk_widget_unparent); - g_clear_pointer (&impl->browse_files_popover, gtk_widget_destroy); + g_clear_pointer (&impl->browse_files_popover, gtk_widget_unparent); g_clear_object (&impl->extra_widget); g_clear_pointer (&impl->bookmarks_manager, _gtk_bookmarks_manager_free); diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index 8f331734ca..36d534f459 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -3911,7 +3911,7 @@ gtk_flow_box_bound_model_changed (GListModel *list, GtkFlowBoxChild *child; child = gtk_flow_box_get_child_at_index (box, position); - gtk_widget_destroy (GTK_WIDGET (child)); + gtk_container_remove (GTK_CONTAINER (box), GTK_WIDGET (child)); } for (i = 0; i < added; i++) @@ -4196,6 +4196,7 @@ gtk_flow_box_bind_model (GtkFlowBox *box, GDestroyNotify user_data_free_func) { GtkFlowBoxPrivate *priv = BOX_PRIV (box); + GtkWidget *child; g_return_if_fail (GTK_IS_FLOW_BOX (box)); g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model)); @@ -4210,7 +4211,8 @@ gtk_flow_box_bind_model (GtkFlowBox *box, g_clear_object (&priv->bound_model); } - gtk_flow_box_forall (GTK_CONTAINER (box), (GtkCallback) gtk_widget_destroy, NULL); + while ((child = gtk_widget_get_first_child (GTK_WIDGET (box)))) + gtk_container_remove (GTK_CONTAINER (box), child); if (model == NULL) return; diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c index 5956b2bbd1..ab0a890671 100644 --- a/gtk/gtkfontchooserwidget.c +++ b/gtk/gtkfontchooserwidget.c @@ -836,11 +836,12 @@ axis_remove (gpointer key, gpointer value, gpointer data) { + GtkFontChooserWidget *fontchooser = data; Axis *a = value; - gtk_widget_destroy (a->label); - gtk_widget_destroy (a->scale); - gtk_widget_destroy (a->spin); + gtk_container_remove (GTK_CONTAINER (fontchooser->axis_grid), a->label); + gtk_container_remove (GTK_CONTAINER (fontchooser->axis_grid), a->scale); + gtk_container_remove (GTK_CONTAINER (fontchooser->axis_grid), a->spin); } static void @@ -1606,7 +1607,7 @@ gtk_font_chooser_widget_update_font_variations (GtkFontChooserWidget *fontchoose if (fontchooser->updating_variations) return FALSE; - g_hash_table_foreach (fontchooser->axes, axis_remove, NULL); + g_hash_table_foreach (fontchooser->axes, axis_remove, fontchooser); g_hash_table_remove_all (fontchooser->axes); if ((fontchooser->level & GTK_FONT_CHOOSER_LEVEL_VARIATIONS) == 0) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 518f3aefbf..ffc3aebfd1 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1716,9 +1716,9 @@ gtk_main_do_event (GdkEvent *event) if (!gtk_window_group_get_current_grab (window_group) || GTK_WIDGET (gtk_widget_get_root (gtk_window_group_get_current_grab (window_group))) == target_widget) { - if (!GTK_IS_WINDOW (target_widget) || + if (GTK_IS_WINDOW (target_widget) && !gtk_window_emit_close_request (GTK_WINDOW (target_widget))) - gtk_widget_destroy (target_widget); + gtk_window_destroy (GTK_WINDOW (target_widget)); } g_object_unref (target_widget); break; diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 0b9ba6e6f2..eb5ac27d7d 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -4229,7 +4229,7 @@ gtk_notebook_real_remove (GtkNotebook *notebook, g_object_ref (tab_label); gtk_notebook_remove_tab_label (notebook, page); if (destroying) - gtk_widget_destroy (tab_label); + gtk_widget_unparent (tab_label); g_object_unref (tab_label); } @@ -6100,7 +6100,7 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook, children = children->next; if (page->default_tab) { - gtk_widget_destroy (page->tab_label); + gtk_widget_unparent (page->tab_label); page->tab_label = NULL; } else @@ -6391,7 +6391,7 @@ gtk_notebook_popup_disable (GtkNotebook *notebook) gtk_container_foreach (GTK_CONTAINER (notebook->menu_box), (GtkCallback) gtk_notebook_menu_label_unparent, NULL); - gtk_widget_destroy (notebook->menu); + notebook->menu = NULL; notebook->menu_box = NULL; diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c index 8522372a43..6ea06f65bb 100644 --- a/gtk/gtkplacesview.c +++ b/gtk/gtkplacesview.c @@ -526,7 +526,7 @@ static void populate_servers (GtkPlacesView *view) { GBookmarkFile *server_list; - GList *children; + GtkWidget *child; gchar **uris; gsize num_uris; gint i; @@ -548,8 +548,8 @@ populate_servers (GtkPlacesView *view) } /* clear previous items */ - children = gtk_container_get_children (GTK_CONTAINER (view->recent_servers_listbox)); - g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy); + while ((child = gtk_widget_get_first_child (view->recent_servers_listbox))) + gtk_container_remove (GTK_CONTAINER (view->recent_servers_listbox), child); gtk_list_store_clear (view->completion_store); @@ -1084,17 +1084,18 @@ fetch_networks (GtkPlacesView *view) static void update_places (GtkPlacesView *view) { - GList *children; GList *mounts; GList *volumes; GList *drives; GList *l; GIcon *icon; GFile *file; + GtkWidget *child; /* Clear all previously added items */ - children = gtk_container_get_children (GTK_CONTAINER (view->listbox)); - g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy); + while ((child = gtk_widget_get_first_child (view->listbox))) + gtk_container_remove (GTK_CONTAINER (view->listbox), child); + view->network_placeholder = NULL; /* Inform clients that we started loading */ gtk_places_view_set_loading (view, TRUE); diff --git a/gtk/gtkprinteroptionwidget.c b/gtk/gtkprinteroptionwidget.c index d8819cb6d5..694fec9e48 100644 --- a/gtk/gtkprinteroptionwidget.c +++ b/gtk/gtkprinteroptionwidget.c @@ -430,40 +430,12 @@ deconstruct_widgets (GtkPrinterOptionWidget *widget) { GtkPrinterOptionWidgetPrivate *priv = widget->priv; - if (priv->check) - { - gtk_widget_destroy (priv->check); - priv->check = NULL; - } - - if (priv->combo) - { - gtk_widget_destroy (priv->combo); - priv->combo = NULL; - } - - if (priv->entry) - { - gtk_widget_destroy (priv->entry); - priv->entry = NULL; - } - - if (priv->image) - { - gtk_widget_destroy (priv->image); - priv->image = NULL; - } - - if (priv->label) - { - gtk_widget_destroy (priv->label); - priv->label = NULL; - } - if (priv->info_label) - { - gtk_widget_destroy (priv->info_label); - priv->info_label = NULL; - } + g_clear_pointer (&priv->check, gtk_widget_unparent); + g_clear_pointer (&priv->combo, gtk_widget_unparent); + g_clear_pointer (&priv->entry, gtk_widget_unparent); + g_clear_pointer (&priv->image, gtk_widget_unparent); + g_clear_pointer (&priv->label, gtk_widget_unparent); + g_clear_pointer (&priv->info_label, gtk_widget_unparent); } static void diff --git a/gtk/gtkprintoperation-win32.c b/gtk/gtkprintoperation-win32.c index 56abcbaf25..009dffcde4 100644 --- a/gtk/gtkprintoperation-win32.c +++ b/gtk/gtkprintoperation-win32.c @@ -1440,7 +1440,7 @@ pageDlgProc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam) op_win32 = op->priv->platform_data; g_signal_emit_by_name (op, "custom-widget-apply", op->priv->custom_widget); - gtk_widget_destroy (op_win32->embed_widget); + g_object_unref (g_object_ref_sink (op_win32->embed_widget)); op_win32->embed_widget = NULL; op->priv->custom_widget = NULL; } @@ -1961,7 +1961,7 @@ gtk_print_operation_run_with_dialog (GtkPrintOperation *op, GlobalFree (printdlgex); if (invisible) - gtk_widget_destroy (invisible); + gtk_window_destroy (GTK_WINDOW (invisible)); return result; } diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index bb5df78053..a4a6db0559 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -1624,16 +1624,14 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog) nrows = grid_rows (GTK_GRID (table)); if (nrows == 0) - gtk_widget_destroy (table); + { + g_object_unref (g_object_ref_sink (table)); + } else { has_advanced = TRUE; frame = wrap_in_frame (group, table); - gtk_widget_show (table); - gtk_widget_show (frame); - - gtk_container_add (GTK_CONTAINER (dialog->advanced_vbox), - frame); + gtk_container_add (GTK_CONTAINER (dialog->advanced_vbox), frame); } } @@ -1941,35 +1939,23 @@ options_changed_cb (GtkPrintUnixDialog *dialog) } static void -remove_custom_widget (GtkWidget *widget, - GtkContainer *container) -{ - gtk_container_remove (container, widget); -} - -static void -extension_point_clear_children (GtkContainer *container) -{ - gtk_container_foreach (container, - (GtkCallback)remove_custom_widget, - container); -} - -static void clear_per_printer_ui (GtkPrintUnixDialog *dialog) { + GtkWidget *child; + if (dialog->finishing_table == NULL) return; - gtk_container_foreach (GTK_CONTAINER (dialog->finishing_table), - (GtkCallback)gtk_widget_destroy, NULL); - gtk_container_foreach (GTK_CONTAINER (dialog->image_quality_table), - (GtkCallback)gtk_widget_destroy, NULL); - gtk_container_foreach (GTK_CONTAINER (dialog->color_table), - (GtkCallback)gtk_widget_destroy, NULL); - gtk_container_foreach (GTK_CONTAINER (dialog->advanced_vbox), - (GtkCallback)gtk_widget_destroy, NULL); - extension_point_clear_children (GTK_CONTAINER (dialog->extension_point)); + while ((child = gtk_widget_get_first_child (dialog->finishing_table))) + gtk_container_remove (GTK_CONTAINER (dialog->finishing_table), child); + while ((child = gtk_widget_get_first_child (dialog->image_quality_table))) + gtk_container_remove (GTK_CONTAINER (dialog->image_quality_table), child); + while ((child = gtk_widget_get_first_child (dialog->color_table))) + gtk_container_remove (GTK_CONTAINER (dialog->color_table), child); + while ((child = gtk_widget_get_first_child (dialog->advanced_vbox))) + gtk_container_remove (GTK_CONTAINER (dialog->advanced_vbox), child); + while ((child = gtk_widget_get_first_child (dialog->extension_point))) + gtk_container_remove (GTK_CONTAINER (dialog->extension_point), child); } static void diff --git a/gtk/gtkshortcutsgroup.c b/gtk/gtkshortcutsgroup.c index 60fa41048f..a44a37d84d 100644 --- a/gtk/gtkshortcutsgroup.c +++ b/gtk/gtkshortcutsgroup.c @@ -268,15 +268,7 @@ gtk_shortcuts_group_dispose (GObject *object) { GtkShortcutsGroup *self = GTK_SHORTCUTS_GROUP (object); - /* - * Since we overload forall(), the inherited destroy() won't work as normal. - * Remove internal widgets ourself. - */ - if (self->title) - { - gtk_widget_destroy (GTK_WIDGET (self->title)); - self->title = NULL; - } + g_clear_pointer ((GtkWidget **)&self->title, gtk_widget_unparent); G_OBJECT_CLASS (gtk_shortcuts_group_parent_class)->dispose (object); } diff --git a/gtk/gtkshortcutssection.c b/gtk/gtkshortcutssection.c index 4df299fe1f..69eefce89a 100644 --- a/gtk/gtkshortcutssection.c +++ b/gtk/gtkshortcutssection.c @@ -200,17 +200,8 @@ gtk_shortcuts_section_dispose (GObject *object) { GtkShortcutsSection *self = GTK_SHORTCUTS_SECTION (object); - if (self->stack) - { - gtk_widget_destroy (GTK_WIDGET (self->stack)); - self->stack = NULL; - } - - if (self->footer) - { - gtk_widget_destroy (GTK_WIDGET (self->footer)); - self->footer = NULL; - } + g_clear_pointer ((GtkWidget **)&self->stack, gtk_widget_unparent); + g_clear_pointer (&self->footer, gtk_widget_unparent); g_list_free (self->groups); self->groups = NULL; @@ -573,6 +564,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self) guint n_columns; guint n_pages; GtkWidget *current_page, *current_column; + GtkWidget *child; /* collect all groups from the current pages */ groups = NULL; @@ -712,8 +704,8 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self) } /* replace the current pages with the new pages */ - children = gtk_container_get_children (GTK_CONTAINER (self->stack)); - g_list_free_full (children, (GDestroyNotify)gtk_widget_destroy); + while ((child = gtk_widget_get_first_child (GTK_WIDGET (self->stack)))) + gtk_container_remove (GTK_CONTAINER (self->stack), child); for (p = pages, n_pages = 0; p; p = p->next, n_pages++) { diff --git a/gtk/gtkshow.c b/gtk/gtkshow.c index f688f79ad2..5ce7994bf9 100644 --- a/gtk/gtkshow.c +++ b/gtk/gtkshow.c @@ -187,7 +187,7 @@ show_uri_done (GObject *object, "%s", error->message); g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); + G_CALLBACK (gtk_window_destroy), NULL); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_window_present (GTK_WINDOW (dialog)); diff --git a/gtk/gtksidebarrow.c b/gtk/gtksidebarrow.c index 8e1f5aa392..9b7c19d86a 100644 --- a/gtk/gtksidebarrow.c +++ b/gtk/gtksidebarrow.c @@ -330,6 +330,8 @@ gtk_sidebar_row_set_property (GObject *object, self->placeholder = g_value_get_boolean (value); if (self->placeholder) { + GtkWidget *child; + g_clear_object (&self->start_icon); g_clear_object (&self->end_icon); g_free (self->label); @@ -347,9 +349,8 @@ gtk_sidebar_row_set_property (GObject *object, g_clear_object (&self->mount); g_clear_object (&self->cloud_provider_account); - gtk_container_foreach (GTK_CONTAINER (self), - (GtkCallback) gtk_widget_destroy, - NULL); + while ((child = gtk_widget_get_first_child (GTK_WIDGET (self)))) + gtk_container_remove (GTK_CONTAINER (self), child); gtk_widget_add_css_class (GTK_WIDGET (self), "sidebar-placeholder-row"); } diff --git a/gtk/gtktext.c b/gtk/gtktext.c index fb50485772..cad6044f42 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -1958,6 +1958,9 @@ gtk_text_dispose (GObject *object) g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_SELECTION_BOUND], gtk_widget_unparent); g_clear_object (&priv->extra_menu); + g_clear_pointer (&priv->magnifier_popover, gtk_widget_unparent); + g_clear_pointer (&priv->placeholder, gtk_widget_unparent); + G_OBJECT_CLASS (gtk_text_parent_class)->dispose (object); } @@ -1972,11 +1975,8 @@ gtk_text_finalize (GObject *object) g_clear_object (&priv->history); g_clear_object (&priv->cached_layout); g_clear_object (&priv->im_context); - g_clear_pointer (&priv->magnifier_popover, gtk_widget_destroy); g_free (priv->im_module); - g_clear_pointer (&priv->placeholder, gtk_widget_unparent); - if (priv->tabs) pango_tab_array_free (priv->tabs); diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c index 9ef3184673..e5963b9177 100644 --- a/gtk/gtktextchild.c +++ b/gtk/gtktextchild.c @@ -236,7 +236,7 @@ child_segment_delete_func (GtkTextLineSegment *seg, { GtkWidget *child = tmp_list->data; - gtk_widget_destroy (child); + gtk_widget_unparent (child); tmp_list = tmp_list->next; } diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 0f1eef567c..549e792087 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -2067,7 +2067,7 @@ gtk_text_view_set_buffer (GtkTextView *text_view, while (priv->anchored_children.length) { AnchoredChild *ac = g_queue_peek_head (&priv->anchored_children); - gtk_widget_destroy (ac->widget); + gtk_widget_unparent (ac->widget); /* ac is now invalid! */ } @@ -3804,6 +3804,9 @@ gtk_text_view_dispose (GObject *object) g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_CURSOR], gtk_widget_unparent); g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_SELECTION_BOUND], gtk_widget_unparent); + g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent); + g_clear_pointer (&priv->magnifier_popover, gtk_widget_unparent); + G_OBJECT_CLASS (gtk_text_view_parent_class)->dispose (object); } @@ -3842,10 +3845,6 @@ gtk_text_view_finalize (GObject *object) text_window_free (priv->text_window); - g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent); - - if (priv->magnifier_popover) - gtk_widget_destroy (priv->magnifier_popover); g_object_unref (priv->im_context); g_free (priv->im_module); diff --git a/gtk/gtktreepopover.c b/gtk/gtktreepopover.c index c60ec32aa0..636cb5180d 100644 --- a/gtk/gtktreepopover.c +++ b/gtk/gtktreepopover.c @@ -376,7 +376,7 @@ row_deleted_cb (GtkTreeModel *model, if (item) { - gtk_widget_destroy (item); + gtk_widget_unparent (item); gtk_cell_area_context_reset (popover->context); } } @@ -405,9 +405,9 @@ row_changed_cb (GtkTreeModel *model, if (is_separator != GTK_IS_SEPARATOR (item)) { - GtkWidget *box= gtk_widget_get_parent (item); + GtkWidget *box = gtk_widget_get_parent (item); - gtk_widget_destroy (item); + gtk_container_remove (GTK_CONTAINER (box), item); item = gtk_tree_popover_create_item (popover, path, iter, FALSE); @@ -732,9 +732,11 @@ static void rebuild_menu (GtkTreePopover *popover) { GtkWidget *stack; + GtkWidget *child; stack = gtk_popover_get_child (GTK_POPOVER (popover)); - gtk_container_foreach (GTK_CONTAINER (stack), (GtkCallback) gtk_widget_destroy, NULL); + while ((child = gtk_widget_get_first_child (stack))) + gtk_container_remove (GTK_CONTAINER (stack), child); if (popover->model) gtk_tree_popover_populate (popover); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index efa2c9d712..db96a38965 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -2073,7 +2073,7 @@ gtk_tree_view_free_rbtree (GtkTreeView *tree_view) static void gtk_tree_view_destroy_search_popover (GtkTreeView *tree_view) { - gtk_widget_destroy (tree_view->search_popover); + gtk_widget_unparent (tree_view->search_popover); tree_view->search_popover = NULL; tree_view->search_entry = NULL; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index e400f80062..4daa725427 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -197,7 +197,6 @@ typedef struct gint title_height; GtkWidget *title_box; GtkWidget *titlebar; - GtkWidget *popup_menu; GtkWidget *key_press_focus; GdkMonitor *initial_fullscreen_monitor; @@ -2416,7 +2415,7 @@ gtk_window_transient_parent_destroyed (GtkWindow *parent, GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window)); if (priv->destroy_with_parent) - gtk_widget_destroy (GTK_WIDGET (window)); + gtk_window_destroy (window); else priv->transient_parent = NULL; } diff --git a/gtk/gtkwindowhandle.c b/gtk/gtkwindowhandle.c index 18a2d4f12e..99b6b01de8 100644 --- a/gtk/gtkwindowhandle.c +++ b/gtk/gtkwindowhandle.c @@ -188,7 +188,7 @@ do_popup_fallback (GtkWindowHandle *self, GtkWindow *window; gboolean maximized, resizable, deletable; - g_clear_pointer (&self->fallback_menu, gtk_widget_destroy); + g_clear_pointer (&self->fallback_menu, gtk_widget_unparent); window = get_window (self); @@ -506,7 +506,7 @@ gtk_window_handle_unrealize (GtkWidget *widget) { GtkWindowHandle *self = GTK_WINDOW_HANDLE (widget); - g_clear_pointer (&self->fallback_menu, gtk_widget_destroy); + g_clear_pointer (&self->fallback_menu, gtk_widget_unparent); GTK_WIDGET_CLASS (gtk_window_handle_parent_class)->unrealize (widget); } diff --git a/gtk/inspector/actions.c b/gtk/inspector/actions.c index c50b71cd46..d7018078ba 100644 --- a/gtk/inspector/actions.c +++ b/gtk/inspector/actions.c @@ -167,7 +167,7 @@ action_removed_cb (GActionGroup *group, row = find_row (sl, action_name); if (row) - gtk_widget_destroy (row); + gtk_container_remove (GTK_CONTAINER (sl->priv->list), row); } static void @@ -312,7 +312,7 @@ gtk_inspector_actions_set_object (GtkInspectorActions *sl, remove_group (sl, page, sl->priv->group); while ((child = gtk_widget_get_first_child (sl->priv->list))) - gtk_widget_destroy (child); + gtk_container_remove (GTK_CONTAINER (sl->priv->list), child); if (GTK_IS_APPLICATION (object)) add_group (sl, page, G_ACTION_GROUP (object)); diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c index 8894a370f8..3fb1221b17 100644 --- a/gtk/inspector/css-node-tree.c +++ b/gtk/inspector/css-node-tree.c @@ -112,7 +112,7 @@ show_node_prop_editor (NodePropEditor *npe) gtk_popover_popup (GTK_POPOVER (popover)); - g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_destroy), NULL); + g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_unparent), NULL); } static void diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c index 5bffd5b1b7..5e52fcd63a 100644 --- a/gtk/inspector/general.c +++ b/gtk/inspector/general.c @@ -532,7 +532,7 @@ populate_display (GdkDisplay *display, GtkInspectorGeneral *gen) gtk_widget_is_ancestor (gen->priv->display_composited, child)) continue; - gtk_widget_destroy (child); + gtk_container_remove (GTK_CONTAINER (list), child); } g_list_free (children); @@ -797,7 +797,7 @@ populate_seats (GtkInspectorGeneral *gen) list = gtk_container_get_children (GTK_CONTAINER (gen->priv->device_box)); for (l = list; l; l = l->next) - gtk_widget_destroy (GTK_WIDGET (l->data)); + gtk_container_remove (GTK_CONTAINER (gen->priv->device_box), GTK_WIDGET (l->data)); g_list_free (list); list = gdk_display_list_seats (gen->priv->display); diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c index 7810854941..e7dd6df908 100644 --- a/gtk/inspector/misc-info.c +++ b/gtk/inspector/misc-info.c @@ -326,11 +326,14 @@ update_info (gpointer data) if (GTK_IS_WIDGET (sl->priv->object)) { + GtkWidget *child; AtkObject *accessible; AtkRole role; GList *list, *l; - gtk_container_forall (GTK_CONTAINER (sl->priv->mnemonic_label), (GtkCallback)gtk_widget_destroy, NULL); + while ((child = gtk_widget_get_first_child (sl->priv->mnemonic_label))) + gtk_container_remove (GTK_CONTAINER (sl->priv->mnemonic_label), child); + list = gtk_widget_list_mnemonic_labels (GTK_WIDGET (sl->priv->object)); for (l = list; l; l = l->next) { diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c index 53600015a5..b26c0fc70e 100644 --- a/gtk/inspector/prop-list.c +++ b/gtk/inspector/prop-list.c @@ -600,8 +600,8 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl, pl->priv->object = object; - while ((w = gtk_widget_get_first_child (pl->priv->list2)) != NULL) - gtk_widget_destroy (w); + while ((w = gtk_widget_get_first_child (pl->priv->list2))) + gtk_container_remove (GTK_CONTAINER (pl->priv->list2), w); for (i = 0; i < num_properties; i++) { diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c index 448898b57f..784e66b269 100644 --- a/gtk/inspector/recorder.c +++ b/gtk/inspector/recorder.c @@ -1179,7 +1179,7 @@ node_property_activated (GtkTreeView *tv, gtk_popover_set_child (GTK_POPOVER (popover), image); gtk_popover_popup (GTK_POPOVER (popover)); - g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_destroy), NULL); + g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_unparent), NULL); g_object_unref (texture); } diff --git a/gtk/inspector/strv-editor.c b/gtk/inspector/strv-editor.c index 2f8528abc9..2471251fd8 100644 --- a/gtk/inspector/strv-editor.c +++ b/gtk/inspector/strv-editor.c @@ -49,7 +49,10 @@ static void remove_string (GtkButton *button, GtkInspectorStrvEditor *editor) { - gtk_widget_destroy (gtk_widget_get_parent (GTK_WIDGET (button))); + GtkWidget *row; + + row = gtk_widget_get_parent (GTK_WIDGET (button)); + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (row)), row); emit_changed (editor); } @@ -128,15 +131,13 @@ void gtk_inspector_strv_editor_set_strv (GtkInspectorStrvEditor *editor, gchar **strv) { - GList *children, *l; + GtkWidget *child; gint i; editor->blocked = TRUE; - children = gtk_container_get_children (GTK_CONTAINER (editor->box)); - for (l = children; l; l = l->next) - gtk_widget_destroy (GTK_WIDGET (l->data)); - g_list_free (children); + while ((child = gtk_widget_get_first_child (editor->box))) + gtk_container_remove (GTK_CONTAINER (editor->box), child); if (strv) { diff --git a/tests/gdkgears.c b/tests/gdkgears.c index c5d866558c..28dd15cc5a 100644 --- a/tests/gdkgears.c +++ b/tests/gdkgears.c @@ -99,7 +99,7 @@ less_gears (GtkButton *button, gpointer data) gears = gtk_widget_get_last_child (GTK_WIDGET (container)); if (gears) - gtk_widget_destroy (gears); + gtk_container_remove (container, gears); } static void diff --git a/tests/testcombo.c b/tests/testcombo.c index 2fb35f8186..2ae3ceb6e0 100644 --- a/tests/testcombo.c +++ b/tests/testcombo.c @@ -79,7 +79,7 @@ create_tree_blaat (void) 2, FALSE, -1); - gtk_widget_destroy (cellview); + g_object_unref (g_object_ref_sink (cellview)); return GTK_TREE_MODEL (store); } @@ -101,7 +101,7 @@ create_empty_list_blaat (void) 1, "dialog-warning", -1); - gtk_widget_destroy (cellview); + g_object_unref (g_object_ref_sink (cellview)); return GTK_TREE_MODEL (store); } @@ -153,7 +153,7 @@ populate_list_blaat (gpointer data) 1, "document-open", -1); - gtk_widget_destroy (cellview); + g_object_unref (g_object_ref_sink (cellview)); } static GtkTreeModel * @@ -203,7 +203,7 @@ create_list_blaat (void) 1, "document-open", -1); - gtk_widget_destroy (cellview); + g_object_unref (g_object_ref_sink (cellview)); return GTK_TREE_MODEL (store); } diff --git a/tests/testdnd3.c b/tests/testdnd3.c index 06f8c77bc0..ac73b5bee4 100644 --- a/tests/testdnd3.c +++ b/tests/testdnd3.c @@ -266,8 +266,8 @@ int main (int argc, char *argv[]) gtk_init (); widget = gtk_color_button_new (); - gtk_widget_destroy (widget); - + g_object_unref (g_object_ref_sink (widget)); + window = gtk_window_new (); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); diff --git a/tests/testlist2.c b/tests/testlist2.c index 9c284417be..90a6fe1539 100644 --- a/tests/testlist2.c +++ b/tests/testlist2.c @@ -40,7 +40,7 @@ row_revealed (GObject *revealer, GParamSpec *pspec, gpointer data) child = gtk_revealer_get_child (GTK_REVEALER (revealer)); g_object_ref (child); gtk_revealer_set_child (GTK_REVEALER (revealer), NULL); - gtk_widget_destroy (GTK_WIDGET (revealer)); + gtk_widget_unparent (GTK_WIDGET (revealer)); gtk_container_add (GTK_CONTAINER (row), child); g_object_unref (child); } diff --git a/testsuite/a11y/misc.c b/testsuite/a11y/misc.c index b2895fadbe..aabbf3f26a 100644 --- a/testsuite/a11y/misc.c +++ b/testsuite/a11y/misc.c @@ -41,8 +41,8 @@ test_popover_parent (void) g_assert (atk_object_get_parent (a) != NULL); - gtk_widget_destroy (w); - gtk_widget_destroy (p); + gtk_widget_unparent (w); + g_object_unref (g_object_ref_sink (p)); } int diff --git a/testsuite/a11y/state/state-record.c b/testsuite/a11y/state/state-record.c index 5f094dce20..3a11c8bee2 100644 --- a/testsuite/a11y/state/state-record.c +++ b/testsuite/a11y/state/state-record.c @@ -101,7 +101,7 @@ do_action (GtkBuilder *builder, const gchar *action, GString *string) GObject *o; o = gtk_builder_get_object (builder, parts[i]); - gtk_widget_destroy (GTK_WIDGET (o)); + g_object_unref (o); } } else if (strcmp (parts[0], "show") == 0) diff --git a/testsuite/gtk/action.c b/testsuite/gtk/action.c index 2ca5901005..768de600d3 100644 --- a/testsuite/gtk/action.c +++ b/testsuite/gtk/action.c @@ -185,7 +185,7 @@ test_text (void) g_assert_cmpint (visibility_changed, ==, 1); - gtk_widget_destroy (box); + g_object_unref (g_object_ref_sink (box)); g_object_unref (clipboard_actions); } @@ -425,7 +425,7 @@ test_enabled (void) g_assert_cmpint (toggled, ==, 1); - gtk_widget_destroy (text); + g_object_unref (g_object_ref_sink (text)); } int diff --git a/testsuite/gtk/filtermodel.c b/testsuite/gtk/filtermodel.c index 99a3e8ed32..53c1d93b6f 100644 --- a/testsuite/gtk/filtermodel.c +++ b/testsuite/gtk/filtermodel.c @@ -483,7 +483,7 @@ filter_test_teardown (FilterTest *fixture, { signal_monitor_free (fixture->monitor); - gtk_widget_destroy (fixture->tree_view); + g_object_unref (g_object_ref_sink (fixture->tree_view)); g_object_unref (fixture->filter); g_object_unref (fixture->store); @@ -2421,7 +2421,7 @@ insert_before (void) g_object_unref (filter); g_object_unref (store); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); } static void @@ -2484,7 +2484,7 @@ insert_child (void) g_object_unref (filter); g_object_unref (store); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); } @@ -2514,7 +2514,7 @@ remove_node (void) gtk_list_store_remove (list, &iter3); gtk_list_store_remove (list, &iter2); - gtk_widget_destroy (view); + g_object_unref (g_object_ref_sink (view)); g_object_unref (filter); g_object_unref (list); } @@ -2552,7 +2552,7 @@ remove_node_vroot (void) gtk_tree_store_remove (tree, &iter3); gtk_tree_store_remove (tree, &iter2); - gtk_widget_destroy (view); + g_object_unref (g_object_ref_sink (view)); g_object_unref (filter); g_object_unref (tree); } @@ -2588,7 +2588,7 @@ remove_vroot_ancestor (void) gtk_tree_store_remove (tree, &parent); - gtk_widget_destroy (view); + g_object_unref (g_object_ref_sink (view)); g_object_unref (filter); g_object_unref (tree); } @@ -2622,7 +2622,7 @@ ref_count_single_level (void) assert_node_ref_count (ref_model, &iter[3], 1); assert_node_ref_count (ref_model, &iter[4], 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_node_ref_count (ref_model, &iter[0], 1); assert_node_ref_count (ref_model, &iter[1], 0); @@ -2692,7 +2692,7 @@ ref_count_two_levels (void) assert_node_ref_count (ref_model, &iter_first, 1); assert_node_ref_count (ref_model, &iter, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_root_level_referenced (ref_model, 1); assert_node_ref_count (ref_model, &iter_first, 1); @@ -2864,7 +2864,7 @@ ref_count_three_levels (void) assert_node_ref_count (ref_model, &iter_parent2_first, 0); assert_node_ref_count (ref_model, &iter_parent2, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model)); @@ -2963,7 +2963,7 @@ ref_count_delete_row (void) assert_node_ref_count (ref_model, &grandparent1, 2); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model)); assert_node_ref_count (ref_model, &grandparent1, 1); @@ -3068,7 +3068,7 @@ ref_count_filter_row_length_1 (void) assert_node_ref_count (ref_model, &level3_1, 0); assert_node_ref_count (ref_model, &level4_1, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model)); assert_node_ref_count (ref_model, &level1_1, 2); @@ -3145,7 +3145,7 @@ ref_count_filter_row_length_1_remove_in_root_level (void) assert_node_ref_count (ref_model, &level3_1, 0); assert_node_ref_count (ref_model, &level4_1, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model)); assert_node_ref_count (ref_model, &level1_1, 2); @@ -3227,7 +3227,7 @@ ref_count_filter_row_length_1_remove_in_child_level (void) assert_node_ref_count (ref_model, &level3_1, 0); assert_node_ref_count (ref_model, &level4_1, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model)); assert_node_ref_count (ref_model, &level1_1, 2); @@ -3370,7 +3370,7 @@ ref_count_filter_row_length_gt_1 (void) assert_node_ref_count (ref_model, &level4_1, 0); assert_node_ref_count (ref_model, &level4_2, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model)); assert_node_ref_count (ref_model, &level1_1, 1); @@ -3470,7 +3470,7 @@ ref_count_filter_row_length_gt_1_visible_children (void) assert_node_ref_count (ref_model, &level4_1, 0); assert_node_ref_count (ref_model, &level4_2, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model)); assert_node_ref_count (ref_model, &level1_1, 1); @@ -3539,7 +3539,7 @@ ref_count_cleanup (void) assert_node_ref_count (ref_model, &iter_parent2_first, 2); assert_node_ref_count (ref_model, &iter_parent2, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_node_ref_count (ref_model, &grandparent1, 1); assert_node_ref_count (ref_model, &grandparent2, 1); @@ -3651,7 +3651,7 @@ ref_count_row_ref (void) assert_node_ref_count (ref_model, &parent1, 1); assert_node_ref_count (ref_model, &iter_parent1, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model)); @@ -3704,7 +3704,7 @@ ref_count_transfer_root_level_insert (void) assert_node_ref_count (ref_model, &grandparent2, 1); assert_node_ref_count (ref_model, &grandparent3, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -3746,7 +3746,7 @@ ref_count_transfer_root_level_remove (void) assert_node_ref_count (ref_model, &grandparent3, 2); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -3823,7 +3823,7 @@ ref_count_transfer_root_level_remove_filtered (void) check_level_length (GTK_TREE_MODEL_FILTER (filter_model), NULL, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -3864,7 +3864,7 @@ ref_count_transfer_root_level_reordered (void) assert_node_ref_count (ref_model, &grandparent3, 1); assert_node_ref_count (ref_model, &grandparent1, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -3965,7 +3965,7 @@ ref_count_transfer_root_level_reordered_filtered (void) assert_node_ref_count (ref_model, &grandparent2, 0); assert_node_ref_count (ref_model, &grandparent1, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -4099,7 +4099,7 @@ ref_count_transfer_root_level_filter (void) gtk_tree_store_set (GTK_TREE_STORE (model), &grandparent4, 0, TRUE, -1); gtk_tree_store_remove (GTK_TREE_STORE (model), &grandparent2); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -4145,7 +4145,7 @@ ref_count_transfer_child_level_insert (void) assert_node_ref_count (ref_model, &parent2, 0); assert_node_ref_count (ref_model, &parent3, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -4193,7 +4193,7 @@ ref_count_transfer_child_level_remove (void) assert_node_ref_count (ref_model, &grandparent1, 3); assert_node_ref_count (ref_model, &parent3, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -4280,7 +4280,7 @@ ref_count_transfer_child_level_remove_filtered (void) check_level_length (GTK_TREE_MODEL_FILTER (filter_model), "0", 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -4326,7 +4326,7 @@ ref_count_transfer_child_level_reordered (void) assert_node_ref_count (ref_model, &parent3, 0); assert_node_ref_count (ref_model, &parent1, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -4436,7 +4436,7 @@ ref_count_transfer_child_level_reordered_filtered (void) assert_node_ref_count (ref_model, &parent2, 0); assert_node_ref_count (ref_model, &parent1, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -4574,7 +4574,7 @@ ref_count_transfer_child_level_filter (void) gtk_tree_store_set (GTK_TREE_STORE (model), &grandparent4, 0, TRUE, -1); gtk_tree_store_remove (GTK_TREE_STORE (model), &grandparent2); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -5012,7 +5012,7 @@ specific_has_child_filter (void) g_object_unref (fixture.filter); g_object_unref (fixture.store); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); } @@ -5176,7 +5176,7 @@ specific_root_has_child_filter (void) g_object_unref (fixture.filter); g_object_unref (fixture.store); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); } static void @@ -5286,7 +5286,7 @@ specific_has_child_filter_on_sort_model (void) g_object_unref (fixture.filter); g_object_unref (fixture.store); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); } static gboolean @@ -5407,7 +5407,7 @@ specific_at_least_2_children_filter (void) g_object_unref (fixture.filter); g_object_unref (fixture.store); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); } static void @@ -5488,7 +5488,7 @@ specific_at_least_2_children_filter_on_sort_model (void) gtk_tree_row_reference_free (ref); g_object_unref (fixture.filter); g_object_unref (fixture.store); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); } @@ -5948,7 +5948,7 @@ specific_bug_311955_clean (void) check_level_length (GTK_TREE_MODEL_FILTER (filter), "0", 3); check_level_length (GTK_TREE_MODEL_FILTER (filter), "0:2", 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); } static void @@ -6467,7 +6467,7 @@ specific_bug_657353_related (void) assert_node_ref_count (ref_model, &node2, 2); assert_node_ref_count (ref_model, &node4, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (ref_model); } @@ -6545,7 +6545,7 @@ specific_bug_657353 (void) */ gtk_list_store_set (store, &iter_c, 0, "CCC hidden", -1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter_model); g_object_unref (sort_model); g_object_unref (store); @@ -6624,7 +6624,7 @@ specific_bug_659022_row_changed_emission (void) gtk_tree_model_row_changed (model, path, &child); gtk_tree_path_free (path); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter); g_object_unref (model); } @@ -6660,7 +6660,7 @@ specific_bug_659022_row_deleted_node_invisible (void) gtk_tree_store_remove (GTK_TREE_STORE (model), &parent); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter); g_object_unref (model); } @@ -6723,7 +6723,7 @@ specific_bug_659022_row_deleted_free_level (void) gtk_tree_store_remove (GTK_TREE_STORE (model), &parent2); gtk_tree_store_remove (GTK_TREE_STORE (model), &parent); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (filter); g_object_unref (model); } diff --git a/testsuite/gtk/gestures.c b/testsuite/gtk/gestures.c index b515470697..1a98400309 100644 --- a/testsuite/gtk/gestures.c +++ b/testsuite/gtk/gestures.c @@ -457,7 +457,7 @@ test_phases (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -516,7 +516,7 @@ test_mixed (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -571,7 +571,7 @@ test_early_exit (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -618,7 +618,7 @@ test_claim_capture (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -665,7 +665,7 @@ test_claim_target (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -718,7 +718,7 @@ test_claim_bubble (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -775,7 +775,7 @@ test_early_claim_capture (void) point_release (&mouse_state, 1); g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -834,7 +834,7 @@ test_late_claim_capture (void) point_release (&mouse_state, 1); g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -886,7 +886,7 @@ test_group (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -945,8 +945,8 @@ test_gestures_outside_grab (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); - gtk_widget_destroy (D); + gtk_window_destroy (A); + gtk_window_destroy (D); } static void @@ -1006,7 +1006,7 @@ test_gestures_inside_grab (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -1057,7 +1057,7 @@ test_multitouch_on_single (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -1132,7 +1132,7 @@ test_multitouch_activation (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } static void @@ -1225,7 +1225,7 @@ test_multitouch_interaction (void) g_string_free (str, TRUE); - gtk_widget_destroy (A); + gtk_window_destroy (A); } int diff --git a/testsuite/gtk/modelrefcount.c b/testsuite/gtk/modelrefcount.c index 2d39d9c227..b3e48ce6ec 100644 --- a/testsuite/gtk/modelrefcount.c +++ b/testsuite/gtk/modelrefcount.c @@ -61,7 +61,7 @@ test_list_reference_during_creation (void) assert_root_level_referenced (ref_model, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_root_level_unreferenced (ref_model); @@ -96,7 +96,7 @@ test_list_reference_after_creation (void) assert_root_level_referenced (ref_model, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_root_level_unreferenced (ref_model); @@ -136,7 +136,7 @@ test_list_reference_reordered (void) assert_root_level_referenced (ref_model, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_root_level_unreferenced (ref_model); @@ -199,7 +199,7 @@ test_tree_reference_during_creation (void) assert_not_entire_model_referenced (ref_model, 1); assert_level_unreferenced (ref_model, &child); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -237,7 +237,7 @@ test_tree_reference_after_creation (void) assert_not_entire_model_referenced (ref_model, 1); assert_level_unreferenced (ref_model, &child); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -280,7 +280,7 @@ test_tree_reference_reordered (void) assert_entire_model_referenced (ref_model, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -330,7 +330,7 @@ test_tree_reference_expand_all (void) assert_not_entire_model_referenced (ref_model, 1); assert_level_unreferenced (ref_model, &child); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -373,7 +373,7 @@ test_tree_reference_collapse_all (void) assert_not_entire_model_referenced (ref_model, 1); assert_level_unreferenced (ref_model, &child); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -440,7 +440,7 @@ test_tree_reference_expand_collapse (void) gtk_tree_path_free (path1); gtk_tree_path_free (path2); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (ref_model); } @@ -486,7 +486,7 @@ test_row_reference_list (void) assert_node_ref_count (ref_model, &iter1, 2); assert_node_ref_count (ref_model, &iter2, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_node_ref_count (ref_model, &iter0, 0); assert_node_ref_count (ref_model, &iter1, 1); @@ -670,7 +670,7 @@ test_row_reference_tree (void) assert_node_ref_count (ref_model, &child2, 0); assert_node_ref_count (ref_model, &grandchild2, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_node_ref_count (ref_model, &iter0, 0); assert_node_ref_count (ref_model, &child0, 0); @@ -927,7 +927,7 @@ test_row_reference_tree_expand (void) gtk_tree_row_reference_free (row_ref1); gtk_tree_row_reference_free (row_ref2); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (ref_model); } diff --git a/testsuite/gtk/propertylookuplistmodel.c b/testsuite/gtk/propertylookuplistmodel.c index 13c129feff..d835295af5 100644 --- a/testsuite/gtk/propertylookuplistmodel.c +++ b/testsuite/gtk/propertylookuplistmodel.c @@ -126,7 +126,7 @@ create_widget_tree (void) static void destroy_widgets (void) { - g_slist_free_full (widgets, (GDestroyNotify) gtk_widget_destroy); + g_slist_free_full (widgets, (GDestroyNotify) gtk_window_destroy); widgets = NULL; } diff --git a/testsuite/gtk/sortmodel.c b/testsuite/gtk/sortmodel.c index 4cf57a07cb..3fbe0f2549 100644 --- a/testsuite/gtk/sortmodel.c +++ b/testsuite/gtk/sortmodel.c @@ -46,7 +46,7 @@ ref_count_single_level (void) assert_entire_model_referenced (ref_model, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -97,7 +97,7 @@ ref_count_two_levels (void) assert_root_level_referenced (ref_model, 1); assert_node_ref_count (ref_model, &iter, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -238,7 +238,7 @@ ref_count_three_levels (void) assert_node_ref_count (ref_model, &iter_parent1, 0); assert_node_ref_count (ref_model, &iter_parent2, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -323,7 +323,7 @@ ref_count_delete_row (void) assert_node_ref_count (ref_model, &grandparent1, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_entire_model_unreferenced (ref_model); @@ -366,7 +366,7 @@ ref_count_cleanup (void) gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view)); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); assert_node_ref_count (ref_model, &grandparent1, 0); assert_node_ref_count (ref_model, &grandparent2, 1); @@ -471,7 +471,7 @@ ref_count_row_ref (void) assert_node_ref_count (ref_model, &parent1, 0); assert_node_ref_count (ref_model, &iter_parent1, 0); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (sort_model); assert_entire_model_unreferenced (ref_model); @@ -563,7 +563,7 @@ ref_count_reorder_single (void) assert_entire_model_referenced (ref_model, 1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (sort_model); assert_entire_model_unreferenced (ref_model); @@ -724,7 +724,7 @@ ref_count_reorder_two (void) assert_level_referenced (ref_model, 1, &iter1); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (sort_model); assert_entire_model_unreferenced (ref_model); @@ -843,7 +843,7 @@ rows_reordered_single_level (void) gtk_tree_path_free (path); signal_monitor_free (monitor); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (sort_model); assert_entire_model_unreferenced (ref_model); @@ -951,7 +951,7 @@ rows_reordered_two_levels (void) gtk_tree_path_free (child_path); signal_monitor_free (monitor); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (sort_model); g_object_unref (ref_model); @@ -1023,7 +1023,7 @@ sorted_insert (void) gtk_tree_path_free (path); signal_monitor_free (monitor); - gtk_widget_destroy (tree_view); + g_object_unref (g_object_ref_sink (tree_view)); g_object_unref (sort_model); g_object_unref (ref_model); diff --git a/testsuite/gtk/templates.c b/testsuite/gtk/templates.c index 016e0724f0..5e2e657852 100644 --- a/testsuite/gtk/templates.c +++ b/testsuite/gtk/templates.c @@ -111,7 +111,7 @@ test_info_bar_basic (void) infobar = gtk_info_bar_new (); g_assert (GTK_IS_INFO_BAR (infobar)); - gtk_widget_destroy (infobar); + g_object_unref (g_object_ref_sink (infobar)); } static void @@ -123,7 +123,7 @@ test_lock_button_basic (void) permission = g_simple_permission_new (TRUE); button = gtk_lock_button_new (permission); g_assert (GTK_IS_LOCK_BUTTON (button)); - gtk_widget_destroy (button); + g_object_unref (g_object_ref_sink (button)); g_object_unref (permission); } @@ -155,7 +155,7 @@ test_scale_button_basic (void) widget = gtk_scale_button_new (0, 100, 10, NULL); g_assert (GTK_IS_SCALE_BUTTON (widget)); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -165,7 +165,7 @@ test_volume_button_basic (void) widget = gtk_volume_button_new (); g_assert (GTK_IS_VOLUME_BUTTON (widget)); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -175,7 +175,7 @@ test_statusbar_basic (void) widget = gtk_statusbar_new (); g_assert (GTK_IS_STATUSBAR (widget)); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -185,7 +185,7 @@ test_search_bar_basic (void) widget = gtk_search_bar_new (); g_assert (GTK_IS_SEARCH_BAR (widget)); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -195,7 +195,7 @@ test_action_bar_basic (void) widget = gtk_action_bar_new (); g_assert (GTK_IS_ACTION_BAR (widget)); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -205,7 +205,7 @@ test_app_chooser_widget_basic (void) widget = gtk_app_chooser_widget_new (NULL); g_assert (GTK_IS_APP_CHOOSER_WIDGET (widget)); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -288,7 +288,7 @@ test_file_chooser_widget_basic (void) while (!done) g_main_context_iteration (NULL, TRUE); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -344,7 +344,7 @@ test_file_chooser_button_basic (void) while (!done) g_main_context_iteration (NULL, TRUE); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -354,7 +354,7 @@ test_font_button_basic (void) widget = gtk_font_button_new (); g_assert (GTK_IS_FONT_BUTTON (widget)); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void @@ -364,7 +364,7 @@ test_font_chooser_widget_basic (void) widget = gtk_font_chooser_widget_new (); g_assert (GTK_IS_FONT_CHOOSER_WIDGET (widget)); - gtk_widget_destroy (widget); + g_object_unref (g_object_ref_sink (widget)); } static void diff --git a/testsuite/gtk/treeview.c b/testsuite/gtk/treeview.c index 0d7b1222bc..c8b0a5fe14 100644 --- a/testsuite/gtk/treeview.c +++ b/testsuite/gtk/treeview.c @@ -68,7 +68,7 @@ test_bug_546005 (void) NULL, FALSE); gtk_tree_path_free (path); - gtk_widget_destroy (view); + g_object_unref (g_object_ref_sink (view)); } static void @@ -99,7 +99,7 @@ test_bug_539377 (void) g_assert (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view), 10, 10, &path, NULL) == FALSE); - gtk_widget_destroy (view); + g_object_unref (g_object_ref_sink (view)); } static void @@ -155,7 +155,7 @@ test_select_collapsed_row (void) gtk_tree_path_free (path); - gtk_widget_destroy (view); + g_object_unref (g_object_ref_sink (view)); } static gboolean @@ -192,7 +192,6 @@ test_row_separator_height (void) gtk_list_store_insert_with_values (store, &iter, 3, 0, "Row content", -1); gtk_list_store_insert_with_values (store, &iter, 4, 0, "Row content", -1); - /*window = gtk_invisible_new ();*/ window = gtk_window_new (); tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); @@ -225,7 +224,7 @@ test_row_separator_height (void) g_assert_cmpint (rect.height, ==, height); g_assert_cmpint (cell_rect.height, ==, height); - gtk_widget_destroy (window); + gtk_window_destroy (GTK_WINDOW (window)); } static void @@ -278,7 +277,7 @@ test_selection_count (void) g_assert_cmpint (gtk_tree_selection_count_selected_rows (selection), ==, 0); - gtk_widget_destroy (view); + g_object_unref (g_object_ref_sink (view)); } static void @@ -332,7 +331,7 @@ test_selection_empty (void) gtk_tree_path_free (path); - gtk_widget_destroy (view); + g_object_unref (g_object_ref_sink (view)); } int |