From 3daedfe0947a34de6fea7378a10b166ddb934f98 Mon Sep 17 00:00:00 2001 From: Steven Luo Date: Thu, 4 Feb 2010 23:32:27 -0800 Subject: [PATCH] Fix some abuses of the D-Bus API dbus_g_proxy_call() needs two G_TYPE_INVALIDs in the arguments, one to terminate the list of input variables and one to terminate the list of output variables. This was causing an error, which we were ignoring; now that we don't get an error every time, print the error message and exit instead of continuing silently in the face of errors. Also, make sure the dbus_g_proxy_new_for_name() call succeeds, instead of potentially passing a NULL tear_proxy to dbus_g_proxy_call(). --- launcher.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/launcher.c b/launcher.c index 93cce2f..76a5321 100644 --- a/launcher.c +++ b/launcher.c @@ -138,12 +138,23 @@ static void launch_tear(struct swb_context *ctx, char *uri) { around by just invoking Tear with exec() if it's not running. */ status = system("pidof tear > /dev/null"); if (WIFEXITED(status) && !WEXITSTATUS(status)) { - if (!tear_proxy) - tear_proxy = dbus_g_proxy_new_for_name(ctx->session_bus, - "com.nokia.tear", "/com/nokia/tear", - "com.nokia.Tear"); - dbus_g_proxy_call(tear_proxy, "OpenAddress", &error, - G_TYPE_STRING, uri, G_TYPE_INVALID); + if (!tear_proxy) { + if (!(tear_proxy = dbus_g_proxy_new_for_name( + ctx->session_bus, + "com.nokia.tear", + "/com/nokia/tear", + "com.nokia.Tear"))) { + printf("Failed to create proxy for com.nokia.Tear D-Bus interface\n"); + exit(1); + } + } + + if (!dbus_g_proxy_call(tear_proxy, "OpenAddress", &error, + G_TYPE_STRING, uri, G_TYPE_INVALID, + G_TYPE_INVALID)) { + printf("Opening window failed: %s\n", error->message); + exit(1); + } if (!ctx->continuous_mode) exit(0); } else { -- 1.7.9.5