C DBus:调用方法返回字符串时失败

时间:2010-09-19 13:22:57

标签: c dbus

请有人告诉我为什么下面的代码在执行时崩溃,(编译顺利)它在旋转的X环境90中向左移动。

    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;

1 个答案:

答案 0 :(得分:0)

得到答案。实际上该服务在Python中运行,并且返回的值不是字符串...因为python中不是强类型。所以返回str(状态)但没有状态解决了我的问题。