C DBus:调用方法返回字符串时失败
问题描述:
不能请别人告诉我为什么下面的代码在执行时崩溃,(编译成功)它在旋转的X环境90左边。C DBus:调用方法返回字符串时失败
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error = NULL;
gchar *name = NULL;
g_type_init();
//Get the connection and ensure the name is not used yet
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (connection == NULL) {
g_warning ("Failed to make connection to system bus: %s",
error->message);
g_error_free (error);
exit(1);
}
proxy = dbus_g_proxy_new_for_name (connection,
"to.some.Service",
"/to/some/Object",
"to.some.Interface");
dbus_g_proxy_call(proxy, "getStatus", &error, G_TYPE_INVALID, G_TYPE_STRING, &name, G_TYPE_INVALID);
printf("Name is: %s\n", name);
return 0;
答
得到答案。实际上该服务在Python中运行,返回的值不是字符串...作为python中不强类型的结果。所以返回str(状态),但没有状态解决了我的问题。
如果它真的只在显示旋转90度时崩溃,我很确定它与您打电话的确切服务有关。请说明它是哪种服务。 – 2010-09-19 13:29:11
该服务由我定义,我认为它的工作正常,因为我写了一个模拟python脚本(与上面的脚本相同),它返回了正确的值。 – deimus 2010-09-19 13:44:31
实际上面的代码在X的第一次启动时工作正常,但如果旋转显示的方向,则无法正常运行。 – deimus 2010-09-19 13:45:20