summaryrefslogtreecommitdiff
path: root/gtk/gtktooltip.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-05-21 18:59:58 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-05-21 19:38:36 -0400
commitaf162b70c5a2dee25ae437c907d57746a7a6eb36 (patch)
treeeaaed363bf0efa55c9446abee9a6a9cf7b1ec168 /gtk/gtktooltip.c
parent061f257e839aace0dd70164cf03efa21eea48cc1 (diff)
downloadgtk+-af162b70c5a2dee25ae437c907d57746a7a6eb36.tar.gz
tooltip: Avoid criticals
It is possible that the target widget is already unparented at the time that we call the tooltips handle_event function. Quietly return in that case, no need to emit a critical.
Diffstat (limited to 'gtk/gtktooltip.c')
-rw-r--r--gtk/gtktooltip.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 36b162885b..4d10edf3e1 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -919,18 +919,21 @@ _gtk_tooltip_handle_event (GtkWidget *target,
GdkSurface *surface;
double x, y;
double nx, ny;
- GtkWidget *native;
+ GtkNative *native;
if (!tooltips_enabled (event))
return;
+ native = gtk_widget_get_native (target);
+ if (!native)
+ return;
+
event_type = gdk_event_get_event_type (event);
surface = gdk_event_get_surface (event);
gdk_event_get_position (event, &x, &y);
- native = GTK_WIDGET (gtk_widget_get_native (target));
- gtk_native_get_surface_transform (GTK_NATIVE (native), &nx, &ny);
- gtk_widget_translate_coordinates (native, target, x - nx, y - ny, &x, &y);
+ gtk_native_get_surface_transform (native, &nx, &ny);
+ gtk_widget_translate_coordinates (GTK_WIDGET (native), target, x - nx, y - ny, &x, &y);
gtk_tooltip_handle_event_internal (event_type, surface, target, x, y);
}