C ++ GeoClue g_object_unref:断言'G_IS_OBJECTobject'失败

问题描述

因此,我最近尝试为我的Raspberry Pi项目之一试用GeoClue,但是我陷入了使用gclue-simple()的困境。运行gclue_simple_new似乎很好,但是当我尝试使用gclue_simple_new_finish()拾取指针时,程序给了我一个运行时错误:

(process:37607): GLib-GIO-CRITICAL **: 16:26:33.873: g_async_result_get_source_object: assertion 'G_IS_ASYNC_RESULT (res)' failed

(process:37607): GLib-GIO-CRITICAL **: 16:26:33.873: g_async_initable_init_finish: assertion 'G_IS_ASYNC_INITABLE (initable)' failed

(process:37607): GLib-GObject-CRITICAL **: 16:26:33.873: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

程序代码在这里:

#include <cstdlib>
#include <iostream>

#include <gclue-simple.h>

void geoclue_callback (GObject* srcObj,GAsyncResult* result,void* userData); 

int main(){
    std::cout << "Program started." << std::endl; 
    
    const char* DESKTOP_ID = "desktop1"; 
    GClueAccuracyLevel accuracy = GCLUE_ACCURACY_LEVEL_CITY; 
    GCancellable* cancellablePtr = NULL; 
    GAsyncReadyCallback callback = geoclue_callback; 
    //gpointer is like void pointer. 
    gpointer usrDataPtr; 

    std::cout << "Variables declared." << std::endl; 

    gclue_simple_new(
        DESKTOP_ID,accuracy,cancellablePtr,callback,usrDataPtr
    ); 

    std::cout << "geoclue service started." << std::endl; 

    GClueSimple* gclueServicePtr; 
    GAsyncResult* rstPtr; 
    GError** errsPtr; 
    //This part here causes runtime error. 
    gclueServicePtr = gclue_simple_new_finish(rstPtr,errsPtr); 

}

void geoclue_callback (GObject* srcObj,void* userData) { 
    //Callback function for when Geoclue comes up with something
    std::cout << "Results Ready." << std::endl; 
}

我只是刚刚接触过地理线索,我以前没有与gtk或GNOME项目相关的任何经验,所以我可能缺少明显的东西。

谢谢!

解决方法

<footer> <script> subscribe.html; </script> <h3>Subscribe &nbsp; &nbsp; NewsLetter &nbsp; &nbsp; Help &nbsp; &nbsp; Instagram &nbsp;</h3> </footer> <object data="html/subscribe.html"> </object> </body> </html> 并不是要告诉您一些结果已经准备就绪,而是要告诉您您的<p>hey</p> <!-- modify this form HTML and place wherever you want your form --> <form action="https://formspree.io/mjvazzkn" method="POST"> <label> Your email: <input type="text" name="_replyto" /> </label> <label> Your message: <textarea name="message"></textarea> </label> <!-- your other form fields go here --> <button type="submit">Send</button> </form> 对象已创建。您需要从callback内部而不是之前调用GClueSimple*。然后,您需要将gclue_simple_new_finish()传递给它,外加一个指向callback初始化错误的指针。

如果初始化失败,

GAsyncResult *result可能会返回GError *error = NULL(以及在错误指针中的gclue_simple_new_finish()对象)。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...