[gtk/wip/chergert/fix-macos-crash] macos: fix crash in imcontextquartz




commit 99a8202015a023000395ce4e7a2fbdc459e3924f
Author: Christian Hergert <christian hergert me>
Date:   Thu Dec 9 12:26:33 2021 -0800

    macos: fix crash in imcontextquartz

 gtk/gtkimcontextquartz.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkimcontextquartz.c b/gtk/gtkimcontextquartz.c
index a64b9a22e0..9adf39200b 100644
--- a/gtk/gtkimcontextquartz.c
+++ b/gtk/gtkimcontextquartz.c
@@ -305,7 +305,7 @@ static void
 quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
 {
   GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
-  GtkWidget* surface_widget = GTK_WIDGET (gdk_surface_get_widget (qc->client_surface));
+  GtkWidget* surface_widget;
   int sx, sy;
   double wx, wy;
 
@@ -317,6 +317,11 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
   if (!qc->focused)
     return;
 
+  surface_widget = GTK_WIDGET (gdk_surface_get_widget (qc->client_surface));
+
+  if (!surface_widget)
+    return;
+
   gdk_surface_get_origin (qc->client_surface, &sx, &sy);
   gtk_widget_translate_coordinates(qc->client_widget, surface_widget,
                                    area->x, area->y, &wx, &wy);


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