[gtk+] Set cell_view to NULL immediately after unparenting
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Set cell_view to NULL immediately after unparenting
- Date: Fri, 17 Dec 2010 15:54:37 +0000 (UTC)
commit 21fc66f1205e7b905bc7d38fc5a7897673cb14e8
Author: Kristian Rietveld <kris gtk org>
Date: Fri Dec 17 16:30:15 2010 +0100
Set cell_view to NULL immediately after unparenting
This way we are sure no invalid pointer will be accessed in between.
gtk/gtkcombobox.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 5de9a0f..dc909fe 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1450,6 +1450,7 @@ static void
gtk_combo_box_add (GtkContainer *container,
GtkWidget *widget)
{
+ gboolean cell_view_removed = FALSE;
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
GtkComboBoxPrivate *priv = combo_box->priv;
@@ -1461,23 +1462,26 @@ gtk_combo_box_add (GtkContainer *container,
return;
}
+ if (priv->cell_view != NULL && widget != priv->cell_view)
+ cell_view_removed = TRUE;
+
if (priv->cell_view &&
gtk_widget_get_parent (priv->cell_view))
{
gtk_widget_unparent (priv->cell_view);
_gtk_bin_set_child (GTK_BIN (container), NULL);
+
+ /* since the cell_view was unparented, it's gone now */
+ priv->cell_view = NULL;
+
gtk_widget_queue_resize (GTK_WIDGET (container));
}
gtk_widget_set_parent (widget, GTK_WIDGET (container));
_gtk_bin_set_child (GTK_BIN (container), widget);
- if (priv->cell_view &&
- widget != priv->cell_view)
+ if (cell_view_removed)
{
- /* since the cell_view was unparented, it's gone now */
- priv->cell_view = NULL;
-
if (!priv->tree_view && priv->separator)
{
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (priv->separator)),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]