[gtk/testsuite-asserts: 12/13] wayland: Build with G_DISABLE_ASSERT




commit b0990aa8e28ce6c57ce927d5cf9278f278bda8d2
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Apr 12 11:59:56 2021 +0100

    wayland: Build with G_DISABLE_ASSERT

 gdk/wayland/gdkdevice-wayland.c  | 22 ++++++++++++++++++++++
 gdk/wayland/gdkdisplay-wayland.c | 13 +++++++++++++
 2 files changed, 35 insertions(+)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 5211cbbbda..f065d2cc30 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -848,7 +848,12 @@ gdk_wayland_device_pad_get_n_groups (GdkDevicePad *pad)
 
   data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
                                     GDK_DEVICE (pad));
+#ifdef G_DISABLE_ASSERT
+  if (data == NULL)
+    return 0;
+#else
   g_assert (data != NULL);
+#endif
 
   return g_list_length (data->mode_groups);
 }
@@ -863,7 +868,12 @@ gdk_wayland_device_pad_get_group_n_modes (GdkDevicePad *pad,
 
   data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
                                     GDK_DEVICE (pad));
+#ifdef G_DISABLE_ASSERT
+  if (data == NULL)
+    return 0;
+#else
   g_assert (data != NULL);
+#endif
 
   group = g_list_nth_data (data->mode_groups, n_group);
   if (!group)
@@ -909,7 +919,12 @@ gdk_wayland_device_pad_get_feature_group (GdkDevicePad        *pad,
 
   data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
                                     GDK_DEVICE (pad));
+#ifdef G_DISABLE_ASSERT
+  if (data == NULL)
+    return -1;
+#else
   g_assert (data != NULL);
+#endif
 
   for (l = data->mode_groups, i = 0; l; l = l->next, i++)
     {
@@ -4236,7 +4251,14 @@ tablet_pad_handle_button (void                     *data,
                        wp_tablet_pad, button, state));
 
   group = tablet_pad_lookup_button_group (pad, button);
+
+#ifdef G_DISABLE_ASSERT
+  if (group == NULL)
+    return;
+#else
   g_assert (group != NULL);
+#endif
+
   n_group = g_list_index (pad->mode_groups, group);
 
   event = gdk_pad_event_new_button (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index ba36d0bb82..5a65999682 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -58,6 +58,19 @@
 
 #include "gdk/gdk-private.h"
 
+/* Keep g_assert() defined even if we disable it globally,
+ * as we use it in many places as a handy mechanism to check
+ * for non-NULL
+ */
+#ifdef G_DISABLE_ASSERT
+# undef g_assert
+# define g_assert(expr)                  G_STMT_START { \
+                                           if G_LIKELY (expr) ; else \
+                                             g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, 
G_STRFUNC, \
+                                                                       #expr); \
+                                         } G_STMT_END
+#endif
+
 /**
  * GdkWaylandDisplay:
  *


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