Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4093142
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:34:51+00:00 2026-05-20T19:34:51+00:00

I’m working on a lib that uses Glib internally to connect to other modules.

  • 0

I’m working on a lib that uses Glib internally to connect to other modules.

This lib has a initialize method that sets up the dbus connection and a terminate method that finalizes all the internal resources (including the dbus connection).
At least it should do this.

However, I can’t make dbus calls again after the terminate method gets called (of course I called the initialize method again before calling the dbus methods again).

I’m using C++ mainly (a few used libs are in C).

Here is my internal dbus initializer:

#ifdef __cplusplus
extern "C" {
#endif

#include <dbus/dbus-glib.h>
#include <stdio.h>

#define _DBUS_SERVICE       "Removed due to restrictions"
#define _DBUS_PATH      "/"
#define _DBUS_INTERFACE "Removed due to restrictions"

static DBusGConnection * my_dbus_conn = NULL;
static DBusGProxy * my_proxy = NULL;

gboolean dbus_init() {
    GError *error = NULL;
    g_type_init();
    my_dbus_conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
    if (my_dbus_conn == NULL) {
        g_printerr("DBUS Connection Error (%s)\n", error->message);
        g_error_free(error);
        return false;
    }
    my_proxy = dbus_g_proxy_new_for_name(my_dbus_conn, _DBUS_SERVICE, _DBUS_PATH, _DBUS_INTERFACE);
    if (my_proxy == NULL) {
        g_printerr("ERROR: DBUS Proxy creation Error (%s)\n", error->message);
        g_error_free(error);
        return false;
    }
    return true;
}

DBusGProxy * dbus_get_proxy() {
    if (my_proxy == NULL) {
        dbus_init();
    }
    return my_proxy;
}

void dbus_term() {
    g_object_unref(G_OBJECT (my_proxy));
    dbus_g_connection_unref(my_dbus_conn);
    my_dbus_conn = NULL;
}

#ifdef __cplusplus
}
#endif

Here is my calling code:

MY_G_DEBUG("Manager", "Creating Server IPC stub...");
this->m_pDbusServer = get_proxy();

if (this->m_pDbusServer == NULL) {
    return;
}

MY_G_DEBUG("Manager", "CheckPoint 1!");
gboolean success;
GError *gerror = NULL;
char **l_pHelloWorldReply;

success = dbus_server_helloworld(this->m_pDbusServer, "Hello World from Manager", &l_pHelloWorldReply, &gerror);

MY_G_DEBUG("Manager", "CheckPoint 2!");

if (success == FALSE) {
    MY_G_DEBUG("Manager", "CheckPoint 3!");
    if (gerror == NULL) {
        MY_G_DEBUG("Manager", "CRITICAL: Hello World call Failed (error not set)");
    } else {
        MY_G_DEBUG("Manager", "CRITICAL: Hello World call Failed (%s)", gerror->message);
        g_error_free(gerror);
        gerror = NULL;
    }
    return;
} else {
    MY_G_DEBUG("Manager", "CheckPoint 4!");
    for (guint ii = 0; l_pHelloWorldReply[ii] != NULL; ii++) {
        MY_G_DEBUG("Manager", "Hello World response %d: %s", ii, l_pHelloWorldReply[ii]);
    }
}

MY_G_DEBUG("Manager", "CheckPoint 5!");

Here is the logging output:

(process:24498): Manager-DEBUG: Checkpoint: 1!
(process:24498): Manager-DEBUG: Checkpoint: 2!
(process:24498): Manager-DEBUG: Checkpoint: 3!
(process:24498): Manager-DEBUG: CRITICAL: Hello World call Failed (error not set)

I got an error message everytime I call the dbus_term function, however I couldn’t manage to fix it.

(process:24498): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GObject'
(process:24498): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

The first time I try to call methods, everything works well…
I strongly believe that’s caused by the dbus_term issue.

Does anyone have any idea why that is happening?

Thanks very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T19:34:51+00:00Added an answer on May 20, 2026 at 7:34 pm

    Don’t use dbus-glib in new code, use GDBus instead.

    GDBus is the new dbus api in glib 2.26. Its advantages over dbus-glib include the use of the GIO async patterns (GAsync*, GCancellable), the use of GVariant for variant types and better threading support.

    See
    http://library.gnome.org/devel/gio/2.28/ch29.html for migrating to GDBus.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.