c++ gdbus - how to fetch the property of interface using gdbus library? - dbus

I would like to know the approach/code snippet to fetch the property from a dbus interface using c++ code snippet.
I have tried the following approaches with error.
Approach#1 using g_dbus_proxy_get_cached_property but it is always returning null
ifproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
flags,
NULL,
"org.freedesktop.NetworkManager",
"org/freedesktop/NetworkManager/Device/0",
"org.freedesktop.NetworkManager.Device",
NULL,
&error);
ret = g_dbus_proxy_get_cached_property(ifproxy, "State")
Approach#2 g_dbus_proxy_call_sync - this one says "org.freedesktop.networkmanager" isn't exported (or may not exist), can't access property "Interface"
ifproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"org.freedesktop.NetworkManager",
"org/freedesktop/NetworkManager/Device/0",
"org.freedesktop.DBus.Properties",
NULL, NULL);
g_assert (ifproxy);
/* Get the object path of the Connection details */
ret = g_dbus_proxy_call_sync (ifproxy,
"Get",
g_variant_new ("(ss)",
"org/freedesktop/NetworkManager/Device/0",
"Interface"),
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
if (!ret) {
g_dbus_error_strip_remote_error (error);
g_warning ("Failed to get property: %s\n",
error->message);
g_error_free (error);
return;
}
name = g_variant_get_string(ret, NULL);
//g_assert(ret != NULL);
g_variant_get (ret, "s", &name);
g_variant_unref (ret);

At least the first form should work (assuming you handle errors in your real code) but there are issues with your D-Bus object paths.
First, valid object paths start with a '/' so you probably wanted /org/freedesktop/NetworkManager/Device/0... except that doesn't seem to be a path NetworkManager uses.
Looking at their API reference, it seems you may really want /org/freedesktop/NetworkManager/Devices/N (note the plural "Devices") but note that you can't really be sure what the last part of the path (N) is going to be. In proper code you should get the devices object path from org.freedesktop.NetworkManager but for debugging you might just use a tool like d-feet to find which objects paths are available and use those.

Thanks a lot #jku.
I was able to solve the issue of encoding.
Sharing the working code below for others.
static void
list_connections (GDBusProxy *proxy)
{
int i;
GError *error = NULL;
GVariant *ret, *ret1;
char **paths;
gchar *name;
GDBusProxy *ifproxy;
GDBusProxyFlags flags;
/* Call ListConnections D-Bus method */
ret = g_dbus_proxy_call_sync (proxy,
"GetDevices",
NULL,
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
if (!ret) {
g_dbus_error_strip_remote_error (error);
g_print ("ListConnections failed: %s\n", error->message);
g_error_free (error);
return;
}
g_variant_get (ret, "(^ao)", &paths);
g_variant_unref (ret);
flags = static_cast<GDBusProxyFlags> (G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START);
for (i = 0; paths[i]; i++)
{
g_print ("%s\n", paths[i]);
/*ifproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
flags,
NULL,
"org.freedesktop.NetworkManager",
paths[i],//"/org/freedesktop/NetworkManager/Devices/0"
"org.freedesktop.NetworkManager.Device",
NULL,
&error);
//name = g_dbus_proxy_get_interface_name(ifproxy);
ret = g_dbus_proxy_get_cached_property(ifproxy, "FirmwareVersion");*/
ifproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager/Devices/0",
"org.freedesktop.DBus.Properties",
NULL, NULL);
g_assert (ifproxy);
ret = g_dbus_proxy_call_sync (ifproxy,
"Get",
g_variant_new ("(ss)",
"org.freedesktop.NetworkManager.Device",
"Interface"),
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
if (!ret) {
g_dbus_error_strip_remote_error (error);
g_warning ("Failed to get property: %s\n",
error->message);
g_error_free (error);
return;
}
g_print("\nType String of Variant:- %s\n", g_variant_get_type_string (ret));
g_variant_get (ret, "(v)", &ret1);
g_variant_unref (ret);
g_print("\nType String of Variant:- %s\n", g_variant_get_type_string (ret1));
g_variant_get (ret1, "s", &name);
g_variant_unref (ret1);
g_print ("Interface name:- %s\n", name);
}
g_strfreev (paths);
}
int
main (int argc, char *argv[])
{
GDBusProxy *proxy;
GDBusProxyFlags flags;
GError *error = NULL;
flags = static_cast<GDBusProxyFlags> (G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START);
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
flags,
NULL, /* GDBusInterfaceInfo */
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
"org.freedesktop.NetworkManager",
NULL, /* GCancellable */
&error);
g_assert (proxy != NULL);
/* List connections of system settings service */
list_connections (proxy);
g_object_unref (proxy);
return 0;
}

Related

Undefined Reference to gdk_pixbuf_save & gdk_pixbuf_new_from_data

I have the following code it is a modification of code found here. In conjunction with this tutorial here.
static void * snapshot_function(void *userdata){
CustomData *data = (CustomData *) userdata;
gint width, height;
GstSample *sample;
GError *error = NULL;
GdkPixbuf *pixbuf;
gint64 duration, position;
GstStateChangeReturn ret;
gboolean res;
GstMapInfo map;
/* Build pipeline */
data->pipeline_snapshot = gst_parse_launch(pipeline_description_snapshot, &error);
if (error) {
gchar *message =
g_strdup_printf("Unable to build pipeline: %s", error->message);
g_clear_error(&error);
set_ui_message(message, data);
g_free(message);
return NULL;
}
if (error != NULL) {
g_print ("could not construct pipeline: %s\n", error->message);
g_error_free (error);
exit (-1);
}
/* get sink */
data->snapshot_sink = gst_bin_get_by_name (GST_BIN (data->pipeline_snapshot), "sink");
/* set to PAUSED to make the first frame arrive in the sink */
ret = gst_element_set_state (data->pipeline_snapshot, GST_STATE_PAUSED);
switch (ret) {
case GST_STATE_CHANGE_FAILURE:
g_print ("failed to play the file\n");
exit (-1);
case GST_STATE_CHANGE_NO_PREROLL:
/* for live sources, we need to set the pipeline to PLAYING before we can
* receive a buffer. We don't do that yet */
g_print ("live sources not supported yet\n");
exit (-1);
default:
break;
}
/* This can block for up to 5 seconds. If your machine is really overloaded,
* it might time out before the pipeline prerolled and we generate an error. A
* better way is to run a mainloop and catch errors there. */
ret = gst_element_get_state (data->pipeline_snapshot, NULL, NULL, 5 * GST_SECOND);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_print ("failed to play the file\n");
exit (-1);
}
/* get the duration */
gst_element_query_duration (data->pipeline_snapshot, GST_FORMAT_TIME, &duration);
if (duration != -1)
/* we have a duration, seek to 5% */
position = duration * 5 / 100;
else
/* no duration, seek to 1 second, this could EOS */
position = 1 * GST_SECOND;
/* seek to the a position in the file. Most files have a black first frame so
* by seeking to somewhere else we have a bigger chance of getting something
* more interesting. An optimisation would be to detect black images and then
* seek a little more */
gst_element_seek_simple (data->pipeline_snapshot, GST_FORMAT_TIME,
GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_FLUSH, position);
/* get the preroll buffer from appsink, this block untils appsink really
* prerolls */
g_signal_emit_by_name (data->snapshot_sink, "pull-preroll", &sample, NULL);
gst_object_unref (data->snapshot_sink);
/* if we have a buffer now, convert it to a pixbuf. It's possible that we
* don't have a buffer because we went EOS right away or had an error. */
if (sample) {
GstBuffer *buffer;
GdkPixbuf *pixbuf;
GstCaps *caps;
GstStructure *s;
/* get the snapshot buffer format now. We set the caps on the appsink so
* that it can only be an rgb buffer. The only thing we have not specified
* on the caps is the height, which is dependent on the pixel-aspect-ratio
* of the source material */
caps = gst_sample_get_caps (sample);
if (!caps) {
g_print ("could not get snapshot format\n");
exit (-1);
}
s = gst_caps_get_structure (caps, 0);
/* we need to get the final caps on the buffer to get the size */
res = gst_structure_get_int (s, "width", &width);
res |= gst_structure_get_int (s, "height", &height);
if (!res) {
g_print ("could not get snapshot dimension\n");
exit (-1);
}
/* create pixmap from buffer and save, gstreamer video buffers have a stride
* that is rounded up to the nearest multiple of 4 */
buffer = gst_sample_get_buffer (sample);
gst_buffer_map (buffer, &map, GST_MAP_READ);
pixbuf = gdk_pixbuf_new_from_data (map.data,GDK_COLORSPACE_RGB, FALSE, 8, width, height, GST_ROUND_UP_4 (width * 3), NULL, NULL);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
gst_buffer_unmap (buffer, &map);
} else {
g_print ("could not make snapshot");
}
/* cleanup and exit */
gst_element_set_state (data->pipeline_snapshot, GST_STATE_NULL);
gst_object_unref (data->pipeline_snapshot);
exit (0);
}
However, when compiling I get the following linker error:
C:/Users/user1/AndroidStudioProjects/Project/app/jni/tutorial-3.c:344:
undefined reference to `gdk_pixbuf_new_from_data'
C:/Users/user1/AndroidStudioProjects/Project/app/jni/tutorial-3.c:347:
undefined reference to `gdk_pixbuf_save' clang++: error: linker
command failed with exit code 1 (use -v to see invocation)
I have #include <gdk-pixbuf-2.0/gdk-pixbuf/gdk-pixbuf.h> at the top of my file, does anyone know what I could potentially be doing wrong?
You have problems with linking, so you need to look at your build script, it seems that you forgot to link the library. For example, if you use cmake, it will look like this:
target_link_libraries(tutorial-3 gdk_pixbuf-2.0)

The name is not activable on g_dbus_proxy_call_sync

On a GNOME Xorg session, to get the return value of method GetIdletime exposed on DBus, you can either use
$ dbus-send --print-reply --dest=org.gnome.Mutter.IdleMonitor /org/gnome/Mutter/IdleMonitor/Core org.gnome.Mutter.IdleMonitor.GetIdletime
or
$ gdbus call --session --dest org.gnome.Mutter.IdleMonitor --object-path /org/gnome/Mutter/IdleMonitor/Core --method org.gnome.Mutter.IdleMonitor.GetIdletime
I need to retrieve this value by using GDBus API, so I wrote the following code
/*
* Compile with:
* gcc -Wall print_user_idle_time-gnome.c -o print_user_idle_time-gnome `pkg-config --libs gio-2.0 --cflags`
*/
#include <gio/gio.h>
static void
print_user_idle_time (GDBusProxy *proxy)
{
guint64 user_idle_time;
gchar *method = "GetIdletime";
GError *error = NULL;
GVariant *ret = NULL;
ret = g_dbus_proxy_call_sync(proxy,
method,
NULL,
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
if (!ret) {
g_dbus_error_strip_remote_error (error);
g_print ("GetIdletime failed: %s\n", error->message);
g_error_free (error);
return;
}
user_idle_time = g_variant_get_uint64 (ret);
g_print("%lu\n", user_idle_time);
g_variant_unref (ret);
}
int
main (int argc, char *argv[])
{
GDBusProxy *proxy = NULL;
gchar *name = "org.gnome.Mutter.IdleMonitor";
gchar *object_path = "/org/gnome/Mutter/IdleMonitor/Core";
gchar *interface_name = "org.gnome.Mutter.IdleMonitor";
/* Create a D-Bus proxy */
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
name,
object_path,
interface_name,
NULL, NULL);
g_assert (proxy != NULL);
print_user_idle_time (proxy);
g_object_unref (proxy);
return 0;
}
But when I run it I get error GetIdletime failed: The name is not activable. What is wrong? Thank you
org.gnome.Mutter.IdleMonitor is on the session bus, not the system bus; so you need to use G_BUS_TYPE_SESSION.

How can I compile my C program with the polkit library?

Today, I tried to use polkit - an application-level toolkit for defining and handling the policy that allows unprivileged processes to speak to privileged processes. In order to understand it better, I tried to download this code:
#include <polkit/polkit.h>
static gboolean
on_tensec_timeout (gpointer user_data)
{
GMainLoop *loop = user_data;
g_print ("Ten seconds has passed. Now exiting.\n");
g_main_loop_quit (loop);
return FALSE;
}
static void
check_authorization_cb (PolkitAuthority *authority,
GAsyncResult *res,
gpointer user_data)
{
GMainLoop *loop = user_data;
PolkitAuthorizationResult *result;
GError *error;
error = NULL;
result = polkit_authority_check_authorization_finish (authority, res, &error);
if (error != NULL)
{
g_print ("Error checking authorization: %s\n", error->message);
g_error_free (error);
}
else
{
const gchar *result_str;
if (polkit_authorization_result_get_is_authorized (result))
{
result_str = "authorized";
}
else if (polkit_authorization_result_get_is_challenge (result))
{
result_str = "challenge";
}
else
{
result_str = "not authorized";
}
g_print ("Authorization result: %s\n", result_str);
}
g_print ("Authorization check has been cancelled and the dialog should now be hidden.\n"
"This process will exit in ten seconds.\n");
g_timeout_add (10000, on_tensec_timeout, loop);
}
static gboolean
do_cancel (GCancellable *cancellable)
{
g_print ("Timer has expired; cancelling authorization check\n");
g_cancellable_cancel (cancellable);
return FALSE;
}
int
main (int argc, char *argv[])
{
pid_t parent_pid;
const gchar *action_id;
GMainLoop *loop;
PolkitSubject *subject;
PolkitAuthority *authority;
GCancellable *cancellable;
g_type_init ();
if (argc != 2)
{
g_printerr ("usage: %s <action_id>\n", argv[0]);
return 1;
}
action_id = argv[1];
loop = g_main_loop_new (NULL, FALSE);
authority = polkit_authority_get_sync (NULL, NULL);
/* Typically mechanisms will use a PolkitSystemBusName since most
* clients communicate with the mechanism via D-Bus. However for
* this simple example we use the process id of the calling process.
*
* Note that if the parent was reaped we have to be careful not to
* check if init(1) is authorized (it always is).
*/
parent_pid = getppid ();
if (parent_pid == 1)
{
g_printerr ("Parent process was reaped by init(1)\n");
return 1;
}
subject = polkit_unix_process_new (parent_pid);
cancellable = g_cancellable_new ();
g_print ("Will cancel authorization check in 10 seconds\n");
/* Set up a 10 second timer to cancel the check */
g_timeout_add (10 * 1000,
(GSourceFunc) do_cancel,
cancellable);
polkit_authority_check_authorization (authority,
subject,
action_id,
NULL, /* PolkitDetails */
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
cancellable,
(GAsyncReadyCallback) check_authorization_cb,
loop);
g_main_loop_run (loop);
g_object_unref (authority);
g_object_unref (subject);
g_object_unref (cancellable);
g_main_loop_unref (loop);
return 0;
}
But when I tried to compile it with gcc, I received this output:
ciao.c:35:27: fatal error: polkit/polkit.h: File o directory non esistente
compilation terminated.
The path polkit/polkit.h is not in the system include path. Make sure you've downloaded and installed PolKit so that the headers and libraries are available.
I solved my problem adding this
pkg-config --cflags glib-2.0 polkit-gobject-1
and this
pkg-config --libs glib-2.0 polkit-gobject-1
to gcc compilation's command in this way
gcc `pkg-config --cflags glib-2.0 polkit-gobject-1` -o polkit PolicyKit/example.c `pkg-config --libs glib-2.0`

Gstreamer 1.2.4.1 windows build. Gstreamer Editing Services Examples on Windows Visual Studio 2012

I have dowloaded and installed http://gstreamer.freedesktop.org/data/pkg/windows/1.2.4.1/ gstreamer. Then I set up Visual Studio 2012 C++ project, add all *.props files. I want to try out Gstreamer Editing Services (GES) example project test4.c:
#include <ges/ges.h>
#include <gst/pbutils/encoding-profile.h>
GstEncodingProfile *make_encoding_profile (gchar * audio, gchar * container);
/* This example will take a series of files and create a audio-only timeline
* containing the first second of each file and render it to the output uri
* using ogg/vorbis */
/* make_encoding_profile
* simple method creating an encoding profile. This is here in
* order not to clutter the main function. */
GstEncodingProfile *
make_encoding_profile (gchar * audio, gchar * container)
{
GstEncodingContainerProfile *profile;
GstEncodingProfile *stream;
GstCaps *caps;
caps = gst_caps_from_string (container);
profile =
gst_encoding_container_profile_new ((gchar *) "ges-test4", NULL, caps,
NULL);
gst_caps_unref (caps);
caps = gst_caps_from_string (audio);
stream = (GstEncodingProfile *)
gst_encoding_audio_profile_new (caps, NULL, NULL, 0);
gst_encoding_container_profile_add_profile (profile, stream);
gst_caps_unref (caps);
return (GstEncodingProfile *) profile;
}
int
main (int argc, gchar ** argv)
{
GESPipeline *pipeline;
GESTimeline *timeline;
GESTrack *tracka;
GESLayer *layer;
GMainLoop *mainloop;
GstEncodingProfile *profile;
gchar *container = (gchar *) "application/ogg";
gchar *audio = (gchar *) "audio/x-vorbis";
gchar *output_uri;
guint i;
GError *err = NULL;
GOptionEntry options[] = {
{"format", 'f', 0, G_OPTION_ARG_STRING, &container,
"Container format", "<GstCaps>"},
{"aformat", 'a', 0, G_OPTION_ARG_STRING, &audio,
"Audio format", "<GstCaps>"},
{NULL}
};
GOptionContext *ctx;
ctx = g_option_context_new ("- renders a sequence of audio files.");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
g_printerr ("Error initializing: %s\n", err->message);
g_option_context_free (ctx);
return -1;
}
if (argc < 3) {
g_print ("Usage: %s <output uri> <list of audio files>\n", argv[0]);
return -1;
}
/* Initialize GStreamer (this will parse environment variables and commandline
* arguments. */
gst_init (&argc, &argv);
/* Initialize the GStreamer Editing Services */
ges_init ();
/* Setup of an audio timeline */
/* This is our main GESTimeline */
timeline = ges_timeline_new ();
tracka = GES_TRACK (ges_audio_track_new ());
/* We are only going to be doing one layer of clips */
layer = ges_layer_new ();
/* Add the tracks and the layer to the timeline */
if (!ges_timeline_add_layer (timeline, layer))
return -1;
if (!ges_timeline_add_track (timeline, tracka))
return -1;
/* Here we've finished initializing our timeline, we're
* ready to start using it... by solely working with the layer ! */
for (i = 2; i < argc; i++) {
gchar *uri = gst_filename_to_uri (argv[i], NULL);
GESUriClip *src = ges_uri_clip_new (uri);
g_assert (src);
g_free (uri);
g_object_set (src, "start", ges_layer_get_duration (layer),
"duration", GST_SECOND, NULL);
/* Since we're using a GESSimpleLayer, objects will be automatically
* appended to the end of the layer */
ges_layer_add_clip (layer, (GESClip *) src);
}
/* In order to view our timeline, let's grab a convenience pipeline to put
* our timeline in. */
pipeline = ges_pipeline_new ();
/* Add the timeline to that pipeline */
if (!ges_pipeline_set_timeline (pipeline, timeline))
return -1;
/* RENDER SETTINGS ! */
/* We set our output URI and rendering setting on the pipeline */
if (gst_uri_is_valid (argv[1])) {
output_uri = g_strdup (argv[1]);
} else {
output_uri = gst_filename_to_uri (argv[1], NULL);
}
profile = make_encoding_profile (audio, container);
if (!ges_pipeline_set_render_settings (pipeline, output_uri, profile))
return -1;
/* We want the pipeline to render (without any preview) */
if (!ges_pipeline_set_mode (pipeline, GES_PIPELINE_MODE_SMART_RENDER))
return -1;
/* The following is standard usage of a GStreamer pipeline (note how you haven't
* had to care about GStreamer so far ?).
*
* We set the pipeline to playing ... */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
/* ... and we start a GMainLoop. GES **REQUIRES** a GMainLoop to be running in
* order to function properly ! */
mainloop = g_main_loop_new (NULL, FALSE);
/* Simple code to have the mainloop shutdown after 4s */
/* FIXME : We should wait for EOS ! */
g_timeout_add_seconds (argc - 1, (GSourceFunc) g_main_loop_quit, mainloop);
g_main_loop_run (mainloop);
return 0;
}
The program runs from the begining to the end without any errors, however
I can't get the music files playing. I think the problem lurks in this piece of code:
if (gst_uri_is_valid (argv[1])) {
output_uri = g_strdup (argv[1]);
} else {
output_uri = gst_filename_to_uri (argv[1], NULL);
}
I don't really know what to type as the first command line argument (the output dir is expected). When I provide any directory and launch program, it waits for a few seconds and then prints out "Press any key to continue...", however I can't hear the music playing neither I find any files in the provided output directory. What is more I was unable to hear any sounds then trying out test1.c, test2.c and test3.c test examples too. Maybe there is special way to provide arguments? My arguments looked like this: D:/output D:/mp3/1.mp3 D:/mp3/2.mp3 .

Unable to free memory

I'm new to C language
I use dbus_g_bus_get() to connect the Session Management signals:
static DBusGProxy * connect_to_session (void)
{
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error = NULL;
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); /* line 1472 */
if (error) {
g_warning ("Couldn't connect to system bus: %s", error->message);
g_error_free(error);
return NULL;
}
/* Get the current session object */
proxy = dbus_g_proxy_new_for_name (connection,
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
"org.gnome.SessionManager");
if (!proxy) {
g_warning ("Unable to get the SessionManager.");
dbus_g_connection_unref (connection);
return NULL;
}
dbus_g_proxy_add_signal (proxy, "SessionOver", G_TYPE_INVALID, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "SessionOver", G_CALLBACK (session_die_cb), NULL, NULL);
g_object_set_data (G_OBJECT (proxy), "connection", connection);
return proxy;
}
call this in main:
int main(int argc, char* argv[])
{
--------------------------------------------
/* Connect the Session Management signals */
proxy = connect_to_session ();
if (proxy) {
DBusGConnection *conn;
conn = (DBusGConnection *)g_object_get_data (G_OBJECT (proxy), "connection");
if (conn)
dbus_g_connection_unref (conn);
g_object_unref (proxy);
}
return 0;
}
and valgrind output this:
32 bytes in 1 blocks are possibly lost in loss record 5,342 of 13,110
at 0x4C2C6AE: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x6F2ABEE: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3703.0)
by 0x6CBC577: g_type_set_qdata (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3703.0)
by 0x513A3D4: ??? (in /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2.2.2)
by 0x512F48C: dbus_g_bus_get (in /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2.2.2)
by 0x40B669: main (gui.c:1472)
I don't know if this report it is false or not.
Thanks
Valgrind has some issues dealing with glbal variables, there is a lot of posts hese at Stackoverflow. You are calling dbus_g_bus_get, and the return is a poiner to a global variable.
DBusGConnection* dbus_g_bus_get (DBusBusType type, GError **error);
Returns a connection to the given bus. The connection is a global variable shared with other callers of this function.
You could also try calling dbus_g_connection_ref after you get the connection.

Resources