Do not hand on startup if the ibus daemon is hung

This commit is contained in:
Kovid Goyal 2018-07-12 11:04:29 +05:30
parent 3c772c3576
commit 98ede457a0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 8 additions and 9 deletions

12
glfw/dbus_glfw.c vendored
View File

@ -130,7 +130,7 @@ toggle_dbus_timeout(DBusTimeout *timeout, void *data) {
DBusConnection*
glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name) {
glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name, GLFWbool register_on_bus) {
DBusError err;
dbus_error_init(&err);
DBusConnection *ans = dbus_connection_open_private(path, &err);
@ -139,13 +139,13 @@ glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name) {
return NULL;
}
dbus_connection_set_exit_on_disconnect(ans, FALSE);
dbus_connection_flush(ans);
dbus_error_free(&err);
if (!dbus_bus_register(ans, &err)) {
report_error(&err, err_msg);
return NULL;
if (register_on_bus) {
if (!dbus_bus_register(ans, &err)) {
report_error(&err, err_msg);
return NULL;
}
}
dbus_connection_flush(ans);
if (!dbus_connection_set_watch_functions(ans, add_dbus_watch, remove_dbus_watch, toggle_dbus_watch, (void*)name, NULL)) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to set DBUS watches on connection to: %s", path);
dbus_connection_close(ans);

2
glfw/dbus_glfw.h vendored
View File

@ -39,7 +39,7 @@ typedef struct {
GLFWbool glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld);
void glfw_dbus_terminate(_GLFWDBUSData *dbus);
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name);
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name, GLFWbool register_on_bus);
void glfw_dbus_close_connection(DBusConnection *conn);
GLFWbool
glfw_dbus_call_method_no_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);

3
glfw/ibus_glfw.c vendored
View File

@ -262,7 +262,7 @@ setup_connection(_GLFWIBUSData *ibus) {
ibus->conn = NULL;
}
debug("Connecting to IBUS daemon @ %s for IME input management\n", ibus->address);
ibus->conn = glfw_dbus_connect_to(ibus->address, "Failed to connect to the IBUS daemon, with error", "ibus");
ibus->conn = glfw_dbus_connect_to(ibus->address, "Failed to connect to the IBUS daemon, with error", "ibus", GLFW_FALSE);
if (!ibus->conn) return GLFW_FALSE;
free((void*)ibus->input_ctx_path); ibus->input_ctx_path = NULL;
if (!glfw_dbus_call_method_with_reply(
@ -270,7 +270,6 @@ setup_connection(_GLFWIBUSData *ibus) {
DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID)) {
return GLFW_FALSE;
}
dbus_connection_flush(ibus->conn);
return GLFW_TRUE;
}