[glibmm/dboles/connect_property_changed-blank] propertyproxy_base: Fix using notify w/o prop name



commit dcd915d0757c91a738e05cbb7cdc6d7154cd62af
Author: Daniel Boles <dboles src gnome org>
Date:   Tue Jun 2 16:07:14 2020 +0100

    propertyproxy_base: Fix using notify w/o prop name
    
    GLib has now specified that if you want to connect to a signal without a
    detail argument, you omit the `::`. So, glibmm users previously
    connecting to `notify::` to listen for changes to all properties broke.
    Fix that by only passing `notify` i.e. no superfluous `::` in that case.
    
    Close https://gitlab.gnome.org/GNOME/glibmm/-/issues/74

 glib/glibmm/propertyproxy_base.cc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/glib/glibmm/propertyproxy_base.cc b/glib/glibmm/propertyproxy_base.cc
index d473c63e..662c8665 100644
--- a/glib/glibmm/propertyproxy_base.cc
+++ b/glib/glibmm/propertyproxy_base.cc
@@ -39,13 +39,21 @@ PropertyProxyConnectionNode::PropertyProxyConnectionNode(sigc::slot_base&& slot,
 {
 }
 
+static const char*
+get_notify_signal_name(const Glib::ustring& property_name)
+{
+  if (property_name.empty())
+    return "notify";
+
+  return ("notify::" + property_name).c_str();
+}
+
 sigc::connection
 PropertyProxyConnectionNode::connect_changed(const Glib::ustring& property_name)
 {
   // connect it to glib
   // 'this' will be passed as the data argument to the callback.
-  const Glib::ustring notify_signal_name = "notify::" + property_name;
-  connection_id_ = g_signal_connect_data(object_, notify_signal_name.c_str(),
+  connection_id_ = g_signal_connect_data(object_, get_notify_signal_name(property_name),
     (GCallback)(&PropertyProxyConnectionNode::callback), this,
     &PropertyProxyConnectionNode::destroy_notify_handler, G_CONNECT_AFTER);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]