grpc-proxy/main-grpc: Don't fall trough assuming we have a wl_display
[src/agl-compositor.git] / grpc-proxy / main-grpc.cpp
index 740594f..5569fc8 100644 (file)
@@ -275,7 +275,7 @@ global_add(void *data, struct wl_registry *reg, uint32_t id,
                sh->shell =
                        static_cast<struct agl_shell *>(wl_registry_bind(reg, id,
                                &agl_shell_interface,
-                               std::min(static_cast<uint32_t>(9), version)));
+                               std::min(static_cast<uint32_t>(10), version)));
                agl_shell_add_listener(sh->shell, &shell_listener, data);
                sh->version = version;
        } else if (strcmp(interface, "wl_output") == 0) {
@@ -299,7 +299,7 @@ global_add_init(void *data, struct wl_registry *reg, uint32_t id,
                sh->shell =
                        static_cast<struct agl_shell *>(wl_registry_bind(reg, id,
                                &agl_shell_interface,
-                               std::min(static_cast<uint32_t>(9), version)));
+                               std::min(static_cast<uint32_t>(10), version)));
                agl_shell_add_listener(sh->shell, &shell_listener_init, data);
                sh->version = version;
        }
@@ -386,6 +386,10 @@ __register_shell_init(void)
        struct shell_data_init *sh = new struct shell_data_init;
 
        wl_display = wl_display_connect(NULL);
+       if (!wl_display) {
+               ret = -1;
+               goto err_failed_display;
+       }
        registry = wl_display_get_registry(wl_display);
        sh->wait_for_bound = true;
        sh->bound_fail = false;
@@ -413,6 +417,8 @@ __register_shell_init(void)
 err:
        wl_registry_destroy(registry);
        wl_display_disconnect(wl_display);
+
+err_failed_display:
        delete sh;
        return ret;
 }
@@ -480,6 +486,10 @@ start_agl_shell_client(void)
 
        struct shell_data *sh = new struct shell_data;
 
+       if (!wl_display) {
+               goto err;
+       }
+
        sh->wl_display = wl_display;
        sh->wait_for_doas = true;
        sh->wait_for_bound = true;
@@ -578,6 +588,7 @@ int main(int argc, char **argv)
                ret = wl_display_dispatch(sh->wl_display);
        }
 
+       thread.join();
        destroy_shell_data(sh);
        return 0;
 }