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.
This commit is contained in:
Nirbheek Chauhan 2019-08-14 14:53:46 +05:30
parent 2e2558b313
commit db3e0c256d
2 changed files with 14 additions and 3 deletions

View File

@ -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
}

View File

@ -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;