Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
if (g_wayland != nullptr) {
AFB_ERROR("Wayland context already initialized?");
if (g_wayland != nullptr) {
AFB_ERROR("Wayland context already initialized?");
}
if (getenv("XDG_RUNTIME_DIR") == nullptr) {
AFB_ERROR("Environment variable XDG_RUNTIME_DIR not set");
}
if (getenv("XDG_RUNTIME_DIR") == nullptr) {
AFB_ERROR("Environment variable XDG_RUNTIME_DIR not set");
}
g_wayland = new wayland;
if (g_wayland->init() == -1) {
AFB_ERROR("Could not connect to compositor");
}
g_wayland = new wayland;
if (g_wayland->init() == -1) {
AFB_ERROR("Could not connect to compositor");
- delete g_wayland;
- return -1;
}
if (char const *e = init_layout()) {
AFB_ERROR("Could not init layout: %s", e);
}
if (char const *e = init_layout()) {
AFB_ERROR("Could not init layout: %s", e);
- sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
- g_wayland->display->get_fd(), EPOLLIN,
- display_event_callback, g_wayland);
+ {
+ int ret = sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
+ g_wayland->display->get_fd(), EPOLLIN,
+ display_event_callback, g_wayland);
+ if (ret < 0) {
+ AFB_ERROR("Could not initialize wayland event handler: %s",
+ std::strerror(-ret));
+ goto error;
+ }
+ }
atexit([] { delete g_wayland; });
return 0;
atexit([] { delete g_wayland; });
return 0;
+
+error:
+ delete g_wayland;
+ g_wayland = nullptr;
+ return -1;
}
int binding_init() noexcept {
}
int binding_init() noexcept {
-void debug_surfaces(afb_req req) {
+void debug_surfaces(afb_req req) noexcept {
CHECK_WAYLAND();
auto a = json_object_new_array();
CHECK_WAYLAND();
auto a = json_object_new_array();
afb_req_success(req, a, "surfaces");
}
afb_req_success(req, a, "surfaces");
}
-void debug_layers(afb_req req) {
+void debug_layers(afb_req req) noexcept {
CHECK_WAYLAND();
auto a = json_object_new_array();
CHECK_WAYLAND();
auto a = json_object_new_array();