[glibmm] DBus::Connection: Pass an empty bus name as nullptr
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] DBus::Connection: Pass an empty bus name as nullptr
- Date: Thu, 4 Feb 2016 15:41:09 +0000 (UTC)
commit 843547cfe72de8958b7cdd5cc1a3390fc5102657
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Thu Feb 4 16:37:08 2016 +0100
DBus::Connection: Pass an empty bus name as nullptr
* gio/src/dbusconnection.[hg|ccg]: Some string parameters in some C functions
accept nullptr, others don't.
call(), call_sync(): bus_name: Pass nullptr for an empty string.
emit_signal(): Only destination_bus_name can be nullptr.
Other string parameters: Pass c_str().
The bug in call() and call_sync() was noticed by Gerlof Fokkema on gtkmm-list.
The bug in emit_signal() is an overreaction to bug 645072. All string
parameters were changed to pass nullptr, but only destination_bus_name
should have been changed.
gio/src/dbusconnection.ccg | 23 ++++++++++-------------
gio/src/dbusconnection.hg | 12 +++++-------
2 files changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/gio/src/dbusconnection.ccg b/gio/src/dbusconnection.ccg
index 113a775..a2f67b3 100644
--- a/gio/src/dbusconnection.ccg
+++ b/gio/src/dbusconnection.ccg
@@ -635,7 +635,7 @@ void Connection::call(
// and deleted in the callback.
auto slot_copy = new SlotAsyncReady(slot);
- g_dbus_connection_call(gobj(), bus_name.c_str(), object_path.c_str(),
+ g_dbus_connection_call(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(),
interface_name.c_str(), method_name.c_str(),
const_cast<GVariant*>(parameters.gobj()), reply_type.gobj(),
static_cast<GDBusCallFlags>(flags), timeout_msec,
@@ -659,7 +659,7 @@ void Connection::call(
// and deleted in the callback.
auto slot_copy = new SlotAsyncReady(slot);
- g_dbus_connection_call(gobj(), bus_name.c_str(), object_path.c_str(),
+ g_dbus_connection_call(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(),
interface_name.c_str(), method_name.c_str(),
const_cast<GVariant*>(parameters.gobj()), reply_type.gobj(),
static_cast<GDBusCallFlags>(flags), timeout_msec, nullptr,
@@ -680,7 +680,7 @@ Glib::VariantContainerBase Connection::call_sync(
GError* gerror = nullptr;
GVariant* const gvariant =
- g_dbus_connection_call_sync(gobj(), bus_name.c_str(), object_path.c_str(),
+ g_dbus_connection_call_sync(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(),
interface_name.c_str(), method_name.c_str(),
const_cast<GVariant*>(parameters.gobj()), reply_type.gobj(),
static_cast<GDBusCallFlags>(flags), timeout_msec,
@@ -706,7 +706,7 @@ Glib::VariantContainerBase Connection::call_sync(
GError* gerror = nullptr;
GVariant* const gvariant =
- g_dbus_connection_call_sync(gobj(), bus_name.c_str(), object_path.c_str(),
+ g_dbus_connection_call_sync(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(),
interface_name.c_str(), method_name.c_str(),
const_cast<GVariant*>(parameters.gobj()), reply_type.gobj(),
static_cast<GDBusCallFlags>(flags), timeout_msec, nullptr, &gerror);
@@ -737,7 +737,7 @@ void Connection::call(
// and deleted in the callback.
auto slot_copy = new SlotAsyncReady(slot);
- g_dbus_connection_call_with_unix_fd_list(gobj(), bus_name.c_str(),
+ g_dbus_connection_call_with_unix_fd_list(gobj(), Glib::c_str_or_nullptr(bus_name),
object_path.c_str(), interface_name.c_str(), method_name.c_str(),
const_cast<GVariant*>(parameters.gobj()), reply_type.gobj(),
static_cast<GDBusCallFlags>(flags), timeout_msec, Glib::unwrap(fd_list),
@@ -762,7 +762,7 @@ void Connection::call(
// and deleted in the callback.
auto slot_copy = new SlotAsyncReady(slot);
- g_dbus_connection_call_with_unix_fd_list(gobj(), bus_name.c_str(),
+ g_dbus_connection_call_with_unix_fd_list(gobj(), Glib::c_str_or_nullptr(bus_name),
object_path.c_str(), interface_name.c_str(), method_name.c_str(),
const_cast<GVariant*>(parameters.gobj()), reply_type.gobj(),
static_cast<GDBusCallFlags>(flags), timeout_msec, Glib::unwrap(fd_list),
@@ -779,15 +779,12 @@ void Connection::emit_signal(
{
GError* gerror = nullptr;
- // Strings are checked to see if they are empty so that nullptr can be passed
- // for those strings to the C API. This is done because some strings such as
- // the bus name can be nullptr in the C API meaning that the signal should be
- // emitted to all the listeners.
+ // destination_bus_name is checked to see if it is empty so that nullptr can be passed
+ // to the C API. This is done because the bus name can be nullptr in the C API,
+ // meaning that the signal should be emitted to all the listeners.
g_dbus_connection_emit_signal(gobj(),
Glib::c_str_or_nullptr(destination_bus_name),
- Glib::c_str_or_nullptr(object_path),
- Glib::c_str_or_nullptr(interface_name),
- Glib::c_str_or_nullptr(signal_name),
+ object_path.c_str(), interface_name.c_str(), signal_name.c_str(),
const_cast<GVariant*>(parameters.gobj()), &gerror);
if(gerror)
diff --git a/gio/src/dbusconnection.hg b/gio/src/dbusconnection.hg
index 065db96..ff226fd 100644
--- a/gio/src/dbusconnection.hg
+++ b/gio/src/dbusconnection.hg
@@ -1,5 +1,3 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-
/* Copyright (C) 2010 The giomm Development Team
*
* This library is free software; you can redistribute it and/or
@@ -627,7 +625,7 @@ public:
* method or <tt>0</tt> if not passing parameters.
* @param slot A SlotAsyncReady to call when the request is satisfied.
* @param cancellable A Cancellable.
- * @param bus_name A unique or well-known bus name or <tt>0</tt> if the
+ * @param bus_name A unique or well-known bus name or an empty string if the
* connection is not a message bus connection.
* @param timeout_msec The timeout in milliseconds, -1 to use the default
* timeout or G_MAXINT for no timeout.
@@ -693,7 +691,7 @@ public:
* @param parameters A Glib::VariantContainerBase tuple with parameters for the
* method or <tt>0</tt> if not passing parameters.
* @param cancellable A Cancellable.
- * @param bus_name A unique or well-known bus name or <tt>0</tt> if the
+ * @param bus_name A unique or well-known bus name or an empty string if the
* connection is not a message bus connection.
* @param timeout_msec The timeout in milliseconds, -1 to use the default
* timeout or G_MAXINT for no timeout.
@@ -744,7 +742,7 @@ public:
* @param slot A SlotAsyncReady to call when the request is satisfied.
* @param cancellable A Cancellable.
* @param fd_list A UnixFDList.
- * @param bus_name A unique or well-known bus name or <tt>0</tt> if the
+ * @param bus_name A unique or well-known bus name or an empty string if the
* connection is not a message bus connection.
* @param timeout_msec The timeout in milliseconds, -1 to use the default
* timeout or G_MAXINT for no timeout.
@@ -801,7 +799,7 @@ public:
const Glib::RefPtr<Cancellable>& cancellable{.?},
const Glib::RefPtr<UnixFDList>& fd_list{.},
Glib::RefPtr<UnixFDList>& out_fd_list{.>>},
- const Glib::ustring& bus_name{.} = Glib::ustring(),
+ const Glib::ustring& bus_name{.NULL} = Glib::ustring(),
int timeout_msec{.} = -1,
CallFlags flags{.} = Gio::DBus::CALL_FLAGS_NONE,
const Glib::VariantType& reply_type{.} = Glib::VariantType()
@@ -818,7 +816,7 @@ public:
* @param interface_name D-Bus interface to emit a signal on.
* @param signal_name The name of the signal to emit.
* @param destination_bus_name The unique bus name for the destination for
- * the signal or <tt>0</tt> to emit to all listeners.
+ * the signal or an empty string to emit to all listeners.
* @param parameters A Glib::VariantContainerBase tuple with parameters for the
* signal or <tt>0</tt> if not passing parameters.
* @throw Glib::Error.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]