代码之家  ›  专栏  ›  技术社区  ›  deimus

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

  •  -1
  • deimus  · 技术社区  · 14 年前

    有人不能告诉我为什么下面的代码在执行时崩溃,(编译正常)它在旋转的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 回复  |  直到 14 年前
        1
  •  0
  •   deimus    14 年前

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