Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-06-10 08:15:38 +0300
committerCampbell Barton <campbell@blender.org>2022-06-10 11:36:10 +0300
commit178c18482546ba7a9e8c7bfdf2164ef6c5993d1a (patch)
tree849f2fbd848d2a11aa47d5f3ddcefbbda8d0dd1b
parent2601b9832dc34ff0346bf3c810d6babc2ca22630 (diff)
GHOST/Wayland: define a log handler to help tracking down errors
Many errors involving mis-use or unexpected situations report an error and close Blender's window buy don't crash, making it difficult to track down when the error occurs. Define an error handler prints the error and a back-trace, it can also be useful for setting a break-point
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 05f2c5d1177..c446963c082 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -171,6 +171,23 @@ struct display_t {
static GHOST_WindowManager *window_manager = nullptr;
+/**
+ * Callback for WAYLAND to run when there is an error.
+ *
+ * \note It's useful to set a break-point on this function as some errors are fatal
+ * (for all intents and purposes) but don't crash the process.
+ */
+static void ghost_wayland_log_handler(const char *msg, va_list arg)
+{
+ fprintf(stderr, "GHOST/Wayland: ");
+ vfprintf(stderr, msg, arg); /* Includes newline. */
+
+ GHOST_TBacktraceFn backtrace_fn = GHOST_ISystem::getBacktraceFn();
+ if (backtrace_fn) {
+ backtrace_fn(stderr); /* Includes newline. */
+ }
+}
+
static void display_destroy(display_t *d)
{
if (d->data_device_manager) {
@@ -1503,6 +1520,8 @@ static const struct wl_registry_listener registry_listener = {
GHOST_SystemWayland::GHOST_SystemWayland() : GHOST_System(), d(new display_t)
{
+ wl_log_set_handler_client(ghost_wayland_log_handler);
+
d->system = this;
/* Connect to the Wayland server. */
d->display = wl_display_connect(nullptr);