[gtk+/wip/dboles/combobox-cleanup: 4/4] combobox: Factor repeated code out to function



commit 9d191b55575d44a58c5b3ef0f52949bc95dd94e1
Author: Daniel Boles <dboles src gnome org>
Date:   Fri Jan 20 03:44:55 2017 +0000

    combobox: Factor repeated code out to function
    
    Rather than having both callers of menu_destroy() repetitively do this:
      • gtk_combo_box_menu_destroy (combo_box);
      • gtk_menu_detach (GTK_MENU (priv->popup_widget));
      • priv->popup_widget = NULL;
    
    Make destroy() do detach() for us, then our detacher nulls popup_widget.

 gtk/gtkcombobox.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index f483925..c2d98c2 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1375,8 +1375,6 @@ gtk_combo_box_remove (GtkContainer *container,
   gtk_widget_queue_resize (GTK_WIDGET (container));
 
   gtk_combo_box_menu_destroy (combo_box);
-  gtk_menu_detach (GTK_MENU (priv->popup_widget));
-  priv->popup_widget = NULL;
 
   gtk_combo_box_create_child (combo_box);
 
@@ -2109,7 +2107,8 @@ gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
                                         0, 0, NULL,
                                         gtk_combo_box_menu_activate, combo_box);
 
-  /* changing the popup window will unref the menu and the children */
+  /* detach() unrefs the menu, and our detacher nulls out popup_widget */
+  gtk_menu_detach (GTK_MENU (priv->popup_widget));
 }
 
 /* callbacks */
@@ -3114,8 +3113,6 @@ gtk_combo_box_dispose(GObject* object)
   GtkComboBoxPrivate *priv = combo_box->priv;
 
   gtk_combo_box_menu_destroy (combo_box);
-  gtk_menu_detach (GTK_MENU (priv->popup_widget));
-  priv->popup_widget = NULL;
 
   if (priv->area)
     {


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