[glib: 1/2] gwin32notificationbackend: Only warn once



commit 39382c7889aeb0bceb9bc815a5af0472679a1672
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Apr 23 10:59:04 2018 +0100

    gwin32notificationbackend: Only warn once
    
    Use a GOnce to make sure we only warn about notifications not being
    supported on Windows once, rather than on each attempted notification.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Helps: https://gitlab.gnome.org/GNOME/glib/issues/1234

 gio/gwin32notificationbackend.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gio/gwin32notificationbackend.c b/gio/gwin32notificationbackend.c
index 7200fdffb..602f3f342 100644
--- a/gio/gwin32notificationbackend.c
+++ b/gio/gwin32notificationbackend.c
@@ -59,12 +59,18 @@ g_win32_notification_backend_send_notification (GNotificationBackend *backend,
                                                 const gchar          *id,
                                                 GNotification        *notification)
 {
+  static gsize warned = 0;
+
   /* FIXME: See https://bugzilla.gnome.org/show_bug.cgi?id=776583. This backend
    * exists purely to stop crashes when applications use g_notification*()
    * on Windows, by providing a dummy backend implementation. (The alternative
    * was to modify all of the backend call sites in g_notification*(), which
    * seemed less scalable.) */
-  g_warning ("Notifications are not yet supported on Windows.");
+  if (g_once_init_enter (&warned))
+    {
+      g_warning ("Notifications are not yet supported on Windows.");
+      g_once_init_leave (&warned, 1);
+    }
 }
 
 static void


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