From 9b4ad136df8530e6cf8bcf26569eb20f6de4170f Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Wed, 3 Jul 2024 18:26:26 -0400 Subject: [PATCH] Allow overriding fatal criticals Allow users and developers to override fatal criticals by setting G_DEBUG to any other value. Part-of: --- .../ephy-web-process-extension-main.c | 2 +- lib/ephy-debug.c | 12 ++++++++++++ lib/ephy-debug.h | 2 ++ src/ephy-main.c | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/embed/web-process-extension/ephy-web-process-extension-main.c b/embed/web-process-extension/ephy-web-process-extension-main.c index 457ff8964..f109fee13 100644 --- a/embed/web-process-extension/ephy-web-process-extension-main.c +++ b/embed/web-process-extension/ephy-web-process-extension-main.c @@ -43,7 +43,7 @@ webkit_web_process_extension_initialize_with_user_data (WebKitWebProcessExtensio gboolean is_webextension; g_autoptr (GError) error = NULL; - g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); + ephy_debug_set_fatal_criticals (); g_variant_get (user_data, "(&sm&sbbb&s)", &guid, &profile_dir, &should_remember_passwords, &private_profile, &is_webextension, &webextension_translations); diff --git a/lib/ephy-debug.c b/lib/ephy-debug.c index f4c63bbd7..743a7a530 100644 --- a/lib/ephy-debug.c +++ b/lib/ephy-debug.c @@ -204,6 +204,18 @@ ephy_profiler_free (EphyProfiler *profiler) g_free (profiler); } +/** + * ephy_debug_set_fatal_critcals: + * + * Sets criticals to fatal unless otherwise specified by `G_DEBUG`. + **/ +void +ephy_debug_set_fatal_criticals () +{ + if (!g_getenv ("G_DEBUG")) + g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); +} + /** * ephy_profiler_start: * @name: name of this new profiler diff --git a/lib/ephy-debug.h b/lib/ephy-debug.h index d4feddc3b..9ab057b41 100644 --- a/lib/ephy-debug.h +++ b/lib/ephy-debug.h @@ -45,4 +45,6 @@ void ephy_profiler_start (const char *name, void ephy_profiler_stop (const char *name); +void ephy_debug_set_fatal_criticals (); + G_END_DECLS diff --git a/src/ephy-main.c b/src/ephy-main.c index a627833a0..02283b528 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -217,7 +217,7 @@ main (int argc, */ LIBXML_TEST_VERSION; - g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); + ephy_debug_set_fatal_criticals (); /* If we're given -remote arguments, translate them */ if (argc >= 2 && strcmp (argv[1], "-remote") == 0) { -- GitLab