From 833b8c329fcfda687897db03c67d6c0507772b94 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 7 Jan 2026 17:56:12 +0000 Subject: [PATCH] DemoRunner: Add workaround for crashing desktop session on Ubuntu The Ubuntu Wayland session crashes completely when adding a system tray component. This is difficult for us to debug (because the desktop goes away taking our debug session with it!), so this change just disables the system tray component on affected platforms. --- examples/DemoRunner/Source/Main.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/DemoRunner/Source/Main.cpp b/examples/DemoRunner/Source/Main.cpp index 322a785b4e..da2b401584 100644 --- a/examples/DemoRunner/Source/Main.cpp +++ b/examples/DemoRunner/Source/Main.cpp @@ -143,10 +143,6 @@ private: setContentOwned (new MainComponent(), false); setVisible (true); - - #if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD - taskbarIcon.reset (new DemoTaskbarComponent()); - #endif } void closeButtonPressed() override { JUCEApplication::getInstance()->systemRequestedQuit(); } @@ -163,7 +159,20 @@ private: MainComponent& getMainComponent() { return *dynamic_cast (getContentComponent()); } private: - std::unique_ptr taskbarIcon; + #if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD + std::unique_ptr taskbarIcon = std::invoke ([&]() -> std::unique_ptr + { + // This is a workaround for a bug in the Ubuntu desktop session on Wayland, which + // crashes when adding an X11 system tray entry. + const auto sessionType = SystemStats::getEnvironmentVariable ("XDG_SESSION_TYPE", {}); + const auto sessionName = SystemStats::getEnvironmentVariable ("XDG_SESSION_DESKTOP", {}); + + if (sessionName.equalsIgnoreCase ("ubuntu") && sessionType.equalsIgnoreCase ("wayland")) + return {}; + + return std::make_unique(); + }); + #endif JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainAppWindow) };