[gtk/wip/matthiasc/popup5: 31/128] Adapt to new popover lifecycle



commit 89a52e57db38d0f7fa7df0a5b86785396dc34d73
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Mar 21 22:12:22 2019 -0400

    Adapt to new popover lifecycle
    
    We need to unparent popovers in dispose.

 gtk/gtkentry.c       | 3 +++
 gtk/gtkplacesview.c  | 2 ++
 gtk/gtkscalebutton.c | 6 +-----
 gtk/gtktext.c        | 9 ++++++---
 4 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 1193d3e8df..3730f8a08e 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -159,6 +159,7 @@ struct _GtkEntryPrivate
 
   GtkWidget     *text;
   GtkWidget     *progress_widget;
+  GtkWidget     *emoji_chooser;
 
   guint         show_emoji_icon         : 1;
   guint         editing_canceled        : 1; /* Only used by GtkCellRendererText */
@@ -1292,6 +1293,8 @@ gtk_entry_dispose (GObject *object)
     }
   g_clear_pointer (&priv->text, gtk_widget_unparent);
 
+  g_clear_pointer (&priv->emoji_chooser, gtk_widget_unparent);
+
   gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
   gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
   gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index dabb486046..abfcb1278f 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -398,6 +398,8 @@ gtk_places_view_destroy (GtkWidget *widget)
   g_cancellable_cancel (priv->cancellable);
   g_cancellable_cancel (priv->networks_fetching_cancellable);
 
+  g_clear_pointer (&priv->server_adresses_popover, gtk_widget_unparent);
+
   GTK_WIDGET_CLASS (gtk_places_view_parent_class)->destroy (widget);
 }
 
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index 61a0ed011b..7e76ea9fdd 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -491,11 +491,7 @@ gtk_scale_button_dispose (GObject *object)
   GtkScaleButton *button = GTK_SCALE_BUTTON (object);
   GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
 
-  if (priv->dock)
-    {
-      gtk_widget_destroy (priv->dock);
-      priv->dock = NULL;
-    }
+  g_clear_pointer (&priv->dock, gtk_widget_unparent);
 
   if (priv->click_id != 0)
     {
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index f026ead3ae..94b9b4160a 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -156,6 +156,7 @@ struct _GtkTextPrivate
 
   char         *im_module;
 
+  GtkWidget     *emoji_completion;
   GtkTextHandle *text_handle;
   GtkWidget     *selection_bubble;
   guint          selection_bubble_timeout_id;
@@ -1785,8 +1786,11 @@ gtk_text_dispose (GObject *object)
       priv->buffer = NULL;
     }
 
+  g_clear_pointer (&priv->emoji_completion, gtk_widget_unparent);
+
   keymap = gdk_display_get_keymap (gtk_widget_get_display (GTK_WIDGET (object)));
   g_signal_handlers_disconnect_by_func (keymap, keymap_direction_changed, self);
+
   G_OBJECT_CLASS (gtk_text_parent_class)->dispose (object);
 }
 
@@ -6648,10 +6652,9 @@ set_enable_emoji_completion (GtkText  *self,
   priv->enable_emoji_completion = value;
 
   if (priv->enable_emoji_completion)
-    g_object_set_data (G_OBJECT (self), "emoji-completion-popup",
-                       gtk_emoji_completion_new (self));
+    priv->emoji_completion = gtk_emoji_completion_new (self);
   else
-    g_object_set_data (G_OBJECT (self), "emoji-completion-popup", NULL);
+    g_clear_pointer (&priv->emoji_completion, gtk_widget_unparent);
 
   g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_ENABLE_EMOJI_COMPLETION]);
 }


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