2010-09-19 73 views
-1

不能請別人告訴我爲什麼下面的代碼在執行時崩潰,(編譯成功)它在旋轉的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; 
+0

如果它真的只在顯示旋轉90度時崩潰,我很確定它與您打電話的確切服務有關。請說明它是哪種服務。 – 2010-09-19 13:29:11

+0

該服務由我定義,我認爲它的工作正常,因爲我寫了一個模擬python腳本(與上面的腳本相同),它返回了正確的值。 – deimus 2010-09-19 13:44:31

+0

實際上面的代碼在X的第一次啓動時工作正常,但如果旋轉顯示的方向,則無法正常運行。 – deimus 2010-09-19 13:45:20

回答

0

得到答案。實際上該服務在Python中運行,返回的值不是字符串...作爲python中不強類型的結果。所以返回str(狀態),但沒有狀態解決了我的問題。