diff options
author | Kjell Ahlstedt <kjell.ahlstedt@bredband.net> | 2016-02-04 16:37:08 +0100 |
---|---|---|
committer | Kjell Ahlstedt <kjell.ahlstedt@bredband.net> | 2016-02-04 16:37:08 +0100 |
commit | 843547cfe72de8958b7cdd5cc1a3390fc5102657 (patch) | |
tree | 83ec5e24c80880dd5cd041f8cf3c4966f10506cc /gio/src/dbusconnection.ccg | |
parent | de3b3fa11ef8da622c2752be08e0b789eaf42572 (diff) | |
download | glibmm-843547cfe72de8958b7cdd5cc1a3390fc5102657.tar.gz |
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.
Diffstat (limited to 'gio/src/dbusconnection.ccg')
-rw-r--r-- | gio/src/dbusconnection.ccg | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/gio/src/dbusconnection.ccg b/gio/src/dbusconnection.ccg index 113a7758..a2f67b36 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) |