tooltip: Never set a window to be its own parent
authorMatthias Clasen <mclasen@redhat.com>
Mon, 30 Dec 2019 14:52:13 +0000 (09:52 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 30 Dec 2019 14:52:13 +0000 (09:52 -0500)
We do get events on the tooltip window too, and
we better ignore them, or bad things may happen,
such as widgets that are their own parents and
cause infinite loops.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2339
gtk/gtktooltip.c
gtk/gtktooltipwindow.c

index 88cf89651df20b1071d7828f366b378f8b18fd0d..1112e6a374eeb717c101a3805b712b16cce16b47 100644 (file)
@@ -495,6 +495,9 @@ gtk_tooltip_set_surface (GtkTooltip *tooltip,
   if (tooltip->native == native)
     return;
 
+  if (GTK_IS_TOOLTIP_WINDOW (native))
+    return;
+
   if (tooltip->native)
     g_object_weak_unref (G_OBJECT (tooltip->native), native_weak_notify, tooltip);
 
index 28e63d095fa27ac23d53d431d5bdc13174d56a37..2467657889ca51769800e70f9a41214b9f245bf8 100644 (file)
@@ -558,6 +558,8 @@ void
 gtk_tooltip_window_set_relative_to (GtkTooltipWindow *window,
                                     GtkWidget        *relative_to)
 {
+  g_return_if_fail (GTK_WIDGET (window) != relative_to);
+
   if (window->relative_to == relative_to)
     return;