From bc0795db95bc628fab60f39c2fb704f6dd0a6a3b Mon Sep 17 00:00:00 2001 From: kunitoki Date: Mon, 16 Mar 2020 13:01:47 +0100 Subject: [PATCH] Don't fail fatally if gui cannot connect to X server MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bug: https://github.com/WeAreROLI/JUCE/issues/422 This is a slight modification of https://github.com/WeAreROLI/JUCE/issues/422 by IOhannes m zmölnig, using early exits rather than longish if-clauses (mainly to minimize the diff). Gbp-Pq: Name 0011-Don-t-fail-fatally-if-gui-cannot-connect-to-X-server.patch --- modules/juce_gui_basics/native/juce_linux_X11.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_linux_X11.cpp b/modules/juce_gui_basics/native/juce_linux_X11.cpp index a2ceb670..7d675413 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11.cpp @@ -149,7 +149,8 @@ XWindowSystem::~XWindowSystem() noexcept ::Display* XWindowSystem::displayUnref() noexcept { - jassert (display != nullptr); + if (!display) + return display; jassert (displayCount.get() > 0); if (--displayCount == 0) @@ -168,7 +169,7 @@ void XWindowSystem::initialiseXDisplay() noexcept if (display == nullptr) { Logger::outputDebugString ("Failed to connect to the X Server."); - Process::terminate(); + return; } // Create a context to store user data associated with Windows we create @@ -223,6 +224,9 @@ void XWindowSystem::initialiseXDisplay() noexcept void XWindowSystem::destroyXDisplay() noexcept { + if (!display) + return; + ScopedXLock xlock (display); XDestroyWindow (display, juce_messageWindowHandle); juce_messageWindowHandle = 0; -- 2.30.2