After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 433984 - Glib::ObjectBase::connect_property_changed doesn't return a sigc::connection
Glib::ObjectBase::connect_property_changed doesn't return a sigc::connection
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: object
2.13.x
Other All
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2007-04-27 23:14 UTC by Philip Langdale
Modified: 2008-01-20 18:54 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18



Description Philip Langdale 2007-04-27 23:14:53 UTC
It does not currently seem possible to easily disconnect a slot connected to a property notification through Glib::ObjectBase::connect_property_changed because no connection is returned.

I believe it is possible to work around this with something like:

sigc::slot<void> foo;
object->connect_property_changed("foo", foo);
sigc::connection con(foo);

but it would be nicer to have the method return the connection in the expected way. I worry that this cannot be done in an ABI compatible way.
Comment 1 Murray Cumming 2007-05-01 20:50:36 UTC
Yes, this would change the ABI. But actually, Glib::ObjectBase::connect_property_changed() is new API that I only addded for the case that the property API is disabled. It's not likely that many people are using it, and embedded projects that are using it can probably handle some breakage. Then again, I guess you are using this.

You can usually do sigc::connection con = widget.property_something().signal_changed().connect().

I did try to document this:
http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1ObjectBase.html#dc6c1e8f094275114d6e2c3ef3a33f98
Comment 2 Philip Langdale 2007-05-02 04:06:29 UTC
Yes, as usual, I'm trying to do something weird. :-)

I have a very large number of generated GObjects which are basically just collections of properties. To use these with glibmm, I'm using a generic wrapper class and the direct property access methods - so I have to use connect_property_changed to listen for property notifications.

It's not a big deal for me to create the connection in the way I originally described so this isn't that big a deal, but it seems like it should be returned.
Comment 3 Kalle Vahlman 2007-05-28 08:46:23 UTC
(In reply to comment #1)
> Yes, this would change the ABI. But actually,
> Glib::ObjectBase::connect_property_changed() is new API that I only addded for
> the case that the property API is disabled. It's not likely that many people
> are using it, and embedded projects that are using it can probably handle some
> breakage.

So new that it is basically never tried?-)

I tried to disable the property API, but run into linking problems. The connect_property_changed() uses PropertyProxyConnectionNode, but given that the property API is disabled, the propertyproxy_base.h will practically be preprocessed to empty. This will compile just fine, but b0rk upon linking time due to missing symbols.

The fix looks obvious (move the ifdefs a bit in propertyproxy_base.cc) and I'll attach a patch for this below.
Comment 4 Kalle Vahlman 2007-05-28 08:51:47 UTC
On second thought, I made a new bug 441766 since this bug is an enhancement request...
Comment 5 Murray Cumming 2008-01-20 18:54:31 UTC
I added a function rather than breaking the API even though the API is quite new:

2008-01-20  Murray Cumming  <murrayc@murrayc.com>

	* glib/glibmm/objectbase.cc:
	* glib/glibmm/objectbase.h: Added connect_property_changed_with_return() 
	because onnect_property_changed() doesn not return a sigc::connection.
	Bug #433984 (Philip Langdale, Kalle Vahlman).

Thank. Please do try using this.