emojichooser: Unparent the variations popup on dispose and before adding a new one

This was causing warnings when destroying the emoji chooser because it
had children left.
This commit is contained in:
Carlos Garcia Campos 2020-06-02 16:35:13 +02:00 committed by Carlos Garcia Campos
parent d2e0ada794
commit 2bf9b37e59

View File

@ -92,6 +92,16 @@ gtk_emoji_chooser_child_init (GtkEmojiChooserChild *child)
{
}
static void
gtk_emoji_chooser_child_dispose (GObject *object)
{
GtkEmojiChooserChild *child = (GtkEmojiChooserChild *)object;
g_clear_pointer (&child->variations, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_emoji_chooser_child_parent_class)->dispose (object);
}
static void
gtk_emoji_chooser_child_size_allocate (GtkWidget *widget,
int width,
@ -148,7 +158,10 @@ gtk_emoji_chooser_child_popup_menu (GtkWidget *widget,
static void
gtk_emoji_chooser_child_class_init (GtkEmojiChooserChildClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = gtk_emoji_chooser_child_dispose;
widget_class->size_allocate = gtk_emoji_chooser_child_size_allocate;
widget_class->focus = gtk_emoji_chooser_child_focus;
widget_class->grab_focus = gtk_emoji_chooser_child_grab_focus;
@ -436,6 +449,7 @@ show_variations (GtkEmojiChooser *chooser,
return;
parent_popover = gtk_widget_get_ancestor (child, GTK_TYPE_POPOVER);
g_clear_pointer (&ch->variations, gtk_widget_unparent);
popover = ch->variations = gtk_popover_new ();
gtk_popover_set_autohide (GTK_POPOVER (popover), TRUE);
gtk_widget_set_parent (popover, child);