[glib: 4/5] glib: Don't call MessageBox() when building for UWP



commit db3e0c256dcd4e10173b7ee0f031e7a38970226e
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Wed Aug 14 14:53:46 2019 +0530

    glib: Don't call MessageBox() when building for UWP
    
    However, it's fine to call it when building for the debug target
    (which uses the debug CRT and hence sets -D_DEBUG), so let's keep that
    around.
    
    The Windows App Certification Kit only runs on apps built in release
    mode.

 glib/gbacktrace.c |  7 +++++++
 glib/gmessages.c  | 10 +++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/glib/gbacktrace.c b/glib/gbacktrace.c
index 34cb1ce46..fa559a104 100644
--- a/glib/gbacktrace.c
+++ b/glib/gbacktrace.c
@@ -192,9 +192,16 @@ g_on_error_query (const gchar *prg_name)
   if (!prg_name)
     prg_name = g_get_prgname ();
 
+  /* MessageBox is allowed on UWP apps only when building against
+   * the debug CRT, which will set -D_DEBUG */
+#if defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP)
   MessageBox (NULL, "g_on_error_query called, program terminating",
               (prg_name && *prg_name) ? prg_name : NULL,
               MB_OK|MB_ICONERROR);
+#else
+  printf ("g_on_error_query called, program '%s' terminating\n",
+      (prg_name && *prg_name) ? prg_name : "(null)");
+#endif
   _exit(0);
 #endif
 }
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 591185605..bb1ab8f84 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -1358,7 +1358,9 @@ g_logv (const gchar   *log_domain,
 
           if ((test_level & G_LOG_FLAG_FATAL) && !masquerade_fatal)
             {
-#ifdef G_OS_WIN32
+              /* MessageBox is allowed on UWP apps only when building against
+               * the debug CRT, which will set -D_DEBUG */
+#if defined(G_OS_WIN32) && (defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP))
               if (win32_keep_fatal_message)
                 {
                   gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
@@ -1366,7 +1368,7 @@ g_logv (const gchar   *log_domain,
                   MessageBox (NULL, locale_msg, NULL,
                               MB_ICONERROR|MB_SETFOREGROUND);
                 }
-#endif /* !G_OS_WIN32 */
+#endif
 
               _g_log_abort (!(test_level & G_LOG_FLAG_RECURSION));
            }
@@ -2675,7 +2677,9 @@ handled:
   /* Abort if the message was fatal. */
   if (log_level & G_LOG_FLAG_FATAL)
     {
-#ifdef G_OS_WIN32
+      /* MessageBox is allowed on UWP apps only when building against
+       * the debug CRT, which will set -D_DEBUG */
+#if defined(G_OS_WIN32) && (defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP))
       if (!g_test_initialized ())
         {
           gchar *locale_msg = NULL;


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