[gtk/wip/albfan/offscreen-window] Prevent crashes on gdk wayland implementation using offscreen windows



commit 1e2d72144a8135e91cbccd963adc3efa261ec6e8
Author: Alberto Fanjul <albertofanjul gmail com>
Date:   Thu Apr 23 11:43:24 2020 +0200

    Prevent crashes on gdk wayland implementation using offscreen windows

 gdk/wayland/gdkwindow-wayland.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 7a89ece98d..cc5e98e5f3 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -2535,12 +2535,17 @@ calculate_moved_to_rect_result (GdkWindow    *window,
                                 gboolean     *flipped_x,
                                 gboolean     *flipped_y)
 {
-  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+  GdkWindowImplWayland *impl;
   GdkWindow *parent;
   gint window_x, window_y;
   gint window_width, window_height;
   GdkRectangle best_rect;
 
+  g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window));
+  g_return_if_fail (GDK_IS_WINDOW_IMPL_WAYLAND (window->impl));
+
+  impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
   parent = translate_from_real_parent_window_geometry (window, &x, &y);
   *final_rect = (GdkRectangle) {
     .x = x,
@@ -5328,10 +5333,16 @@ void
 gdk_wayland_window_restore_shortcuts (GdkWindow *window,
                                       GdkSeat   *gdk_seat)
 {
-  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
-  struct wl_seat *seat = gdk_wayland_seat_get_wl_seat (gdk_seat);
+  GdkWindowImplWayland *impl;
+  struct wl_seat *seat;
   struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor;
 
+  g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window));
+  g_return_if_fail (GDK_IS_WINDOW_IMPL_WAYLAND (window->impl));
+
+  impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+  seat = gdk_wayland_seat_get_wl_seat (gdk_seat);
+
   inhibitor = gdk_wayland_window_get_inhibitor (impl, seat);
   if (inhibitor == NULL)
     return; /* Not inhibitted */


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