diff options
author | Garrett Brown <themagnificentmrb@gmail.com> | 2023-01-09 15:25:54 -0800 |
---|---|---|
committer | Garrett Brown <themagnificentmrb@gmail.com> | 2023-01-14 16:22:48 -0800 |
commit | 34882d4ea2e16b457caf67fd684c24e411c6c13a (patch) | |
tree | 5a846ea36b9b6816edd03bc7689ab05223f9bd21 | |
parent | 6048b035a3d7dd21f1e4870a783ad27f8b450e1f (diff) | |
download | xbmc-34882d4ea2e16b457caf67fd684c24e411c6c13a.tar.xz |
Fix crash on X11 when WAYLAND_DISPLAY is set
-rw-r--r-- | xbmc/windowing/wayland/Connection.cpp | 19 | ||||
-rw-r--r-- | xbmc/windowing/wayland/Connection.h | 1 | ||||
-rw-r--r-- | xbmc/windowing/wayland/WinSystemWayland.cpp | 7 |
3 files changed, 23 insertions, 4 deletions
diff --git a/xbmc/windowing/wayland/Connection.cpp b/xbmc/windowing/wayland/Connection.cpp index 45d2fcdf72..9d45be63b6 100644 --- a/xbmc/windowing/wayland/Connection.cpp +++ b/xbmc/windowing/wayland/Connection.cpp @@ -8,17 +8,32 @@ #include "Connection.h" +#include "utils/log.h" + #include <cassert> +#include <stdexcept> using namespace KODI::WINDOWING::WAYLAND; CConnection::CConnection() { - m_display.reset(new wayland::display_t); + try + { + m_display = std::make_unique<wayland::display_t>(); + } + catch (const std::exception& err) + { + CLog::Log(LOGERROR, "Wayland connection error: {}", err.what()); + } +} + +bool CConnection::HasDisplay() const +{ + return static_cast<bool>(m_display); } wayland::display_t& CConnection::GetDisplay() { assert(m_display); return *m_display; -}
\ No newline at end of file +} diff --git a/xbmc/windowing/wayland/Connection.h b/xbmc/windowing/wayland/Connection.h index 33469bfe9a..b1badd4249 100644 --- a/xbmc/windowing/wayland/Connection.h +++ b/xbmc/windowing/wayland/Connection.h @@ -27,6 +27,7 @@ class CConnection public: CConnection(); + bool HasDisplay() const; wayland::display_t& GetDisplay(); private: diff --git a/xbmc/windowing/wayland/WinSystemWayland.cpp b/xbmc/windowing/wayland/WinSystemWayland.cpp index 9ea0c8fb12..9733339ad8 100644 --- a/xbmc/windowing/wayland/WinSystemWayland.cpp +++ b/xbmc/windowing/wayland/WinSystemWayland.cpp @@ -158,11 +158,14 @@ bool CWinSystemWayland::InitWindowSystem() wayland::set_log_handler([](const std::string& message) { CLog::Log(LOGWARNING, "wayland-client log message: {}", message); }); + CLog::LogF(LOGINFO, "Connecting to Wayland server"); + m_connection = std::make_unique<CConnection>(); + if (!m_connection->HasDisplay()) + return false; + VIDEOPLAYER::CProcessInfoWayland::Register(); RETRO::CRPProcessInfoWayland::Register(); - CLog::LogF(LOGINFO, "Connecting to Wayland server"); - m_connection.reset(new CConnection); m_registry.reset(new CRegistry{*m_connection}); m_registry->RequestSingleton(m_compositor, 1, 4); |