summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-07-05 16:23:17 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commit8e831f9b2e461c94a8ee0e229812bcf2d42ae2a5 (patch)
tree537ae5e6c9686d17034809753b23fc3c52770e0a /src/main.cpp
parent96e87229a885492201a9fe8d4e6afcc91a8775d5 (diff)
Check for g_wayland in every API call.
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 13e6ab2..f5d33c7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -179,6 +179,15 @@ int binding_init() noexcept {
return -1;
}
+#define CHECK_WAYLAND() \
+ do { \
+ if (g_wayland == nullptr) { \
+ afb_req_fail(req, "failed", \
+ "Binding not initialized, did the compositor die?"); \
+ return; \
+ } \
+ } while (0)
+
// _ _ _ _ ____
// __| | ___| |__ _ _ __ _ ___| |_ __ _| |_ _ _ ___ / /\ \
// / _` |/ _ \ '_ \| | | |/ _` | / __| __/ _` | __| | | / __| | | |
@@ -189,11 +198,7 @@ void debug_status(struct afb_req req) noexcept {
// Quick and dirty, dump current surfaces and layers
AFB_REQ_DEBUG(req, "status");
- if (g_wayland == nullptr) {
- afb_req_fail(req, "failed",
- "Binding not initialized, did the compositor die?");
- return;
- }
+ CHECK_WAYLAND();
try {
json j;
@@ -229,6 +234,8 @@ void debug_status(struct afb_req req) noexcept {
}
void debug_surfaces(afb_req req) {
+ CHECK_WAYLAND();
+
auto a = json_object_new_array();
if (!g_wayland->controller->surfaces.empty()) {
@@ -241,6 +248,8 @@ void debug_surfaces(afb_req req) {
}
void debug_layers(afb_req req) {
+ CHECK_WAYLAND();
+
auto a = json_object_new_array();
if (!g_wayland->controller->layers.empty()) {