77 lines
2.6 KiB
Diff
77 lines
2.6 KiB
Diff
|
From 951ce45d4c229a4f6abea39acd4f7dc759d9ef10 Mon Sep 17 00:00:00 2001
|
||
|
From: Michael Catanzaro <mcatanzaro@gnome.org>
|
||
|
Date: Fri, 9 Apr 2021 13:10:02 -0500
|
||
|
Subject: [PATCH 01/13] Add some checks to ensure we properly bind server
|
||
|
globals
|
||
|
|
||
|
If we fail to bind any global objects, we are going to crash. Let's do
|
||
|
that as nicely as possible using g_error(), rather than dereferencing
|
||
|
null pointers later on.
|
||
|
|
||
|
Suggested by #145
|
||
|
|
||
|
(cherry picked from commit a4eb79d12fc851ea7cef616afa0d77668e83ea61)
|
||
|
---
|
||
|
src/extensions/audio.cpp | 3 +++
|
||
|
src/extensions/video-plane-display-dmabuf.cpp | 3 +++
|
||
|
src/ws-client.cpp | 8 ++++++++
|
||
|
3 files changed, 14 insertions(+)
|
||
|
|
||
|
diff --git a/src/extensions/audio.cpp b/src/extensions/audio.cpp
|
||
|
index b3043ac..5d2dd91 100644
|
||
|
--- a/src/extensions/audio.cpp
|
||
|
+++ b/src/extensions/audio.cpp
|
||
|
@@ -159,6 +159,9 @@ public:
|
||
|
wl_display_roundtrip_queue(display, eventQueue);
|
||
|
wl_registry_destroy(registry);
|
||
|
|
||
|
+ if (!m_wl.audio)
|
||
|
+ g_error("Failed to bind wpe_audio");
|
||
|
+
|
||
|
wl_event_queue_destroy(eventQueue);
|
||
|
}
|
||
|
|
||
|
diff --git a/src/extensions/video-plane-display-dmabuf.cpp b/src/extensions/video-plane-display-dmabuf.cpp
|
||
|
index 953cb4c..96fabcf 100644
|
||
|
--- a/src/extensions/video-plane-display-dmabuf.cpp
|
||
|
+++ b/src/extensions/video-plane-display-dmabuf.cpp
|
||
|
@@ -159,6 +159,9 @@ public:
|
||
|
wl_display_roundtrip_queue(display, eventQueue);
|
||
|
wl_registry_destroy(registry);
|
||
|
|
||
|
+ if (!m_wl.videoPlaneDisplayDmaBuf)
|
||
|
+ g_error("Failed to bind wpe_video_plane_display_dmabuf");
|
||
|
+
|
||
|
wl_event_queue_destroy(eventQueue);
|
||
|
}
|
||
|
|
||
|
diff --git a/src/ws-client.cpp b/src/ws-client.cpp
|
||
|
index 6dc98ca..4ffa090 100644
|
||
|
--- a/src/ws-client.cpp
|
||
|
+++ b/src/ws-client.cpp
|
||
|
@@ -126,6 +126,9 @@ BaseBackend::BaseBackend(int hostFD)
|
||
|
wl_display_roundtrip(m_wl.display);
|
||
|
wl_registry_destroy(registry);
|
||
|
|
||
|
+ if (!m_wl.wpeBridge)
|
||
|
+ g_error("Failed to bind wpe_bridge");
|
||
|
+
|
||
|
wpe_bridge_add_listener(m_wl.wpeBridge, &s_bridgeListener, this);
|
||
|
wpe_bridge_initialize(m_wl.wpeBridge);
|
||
|
wl_display_roundtrip(m_wl.display);
|
||
|
@@ -204,6 +207,11 @@ void BaseTarget::initialize(BaseBackend& backend)
|
||
|
wl_display_roundtrip_queue(display, m_wl.eventQueue);
|
||
|
wl_registry_destroy(registry);
|
||
|
|
||
|
+ if (!m_wl.compositor)
|
||
|
+ g_error("Failed to bind wl_compositor");
|
||
|
+ if (!m_wl.wpeBridge)
|
||
|
+ g_error("Failed to bind wpe_bridge");
|
||
|
+
|
||
|
m_wl.surface = wl_compositor_create_surface(m_wl.compositor);
|
||
|
wl_proxy_set_queue(reinterpret_cast<struct wl_proxy*>(m_wl.surface), m_wl.eventQueue);
|
||
|
|
||
|
--
|
||
|
2.31.1
|
||
|
|