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 617571 - Reference count bug in signals
Reference count bug in signals
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-05-03 20:38 UTC by pancake
Modified: 2010-06-07 19:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
valac fail.vala --pkg gtk+-2.0 --pkg posix (1.20 KB, application/octet-stream)
2010-05-03 20:38 UTC, pancake
  Details
deprecate obj.signal += callback (1.04 KB, patch)
2010-06-01 20:07 UTC, Luca Bruno
none Details | Review

Description pancake 2010-05-03 20:38:53 UTC
Created attachment 160224 [details]
valac fail.vala --pkg gtk+-2.0 --pkg posix

When using '+=' instead of '.connect()' on signals, closures are failing because the passed struct is freed just after attaching the callback.

Attached is a sample code to reproduce the issue.
Comment 1 Luca Bruno 2010-05-27 19:27:40 UTC
+= is deprecated, latest patches have been written to work with .connect() rather than with +=, you shouldn't be using it.
Comment 2 pancake 2010-06-01 11:04:01 UTC
If its deprecated and buggy, Vala should WARN with a "deprecated" message or just, give an error. It's a pity to fall in bugs because you are using something deprecated but nobody warns or bans you to do it.

I would prefer not to allow += anymore in next release.
Comment 3 Luca Bruno 2010-06-01 20:07:03 UTC
Created attachment 162496 [details] [review]
deprecate obj.signal += callback
Comment 4 Jürg Billeter 2010-06-07 19:01:46 UTC
commit c353329b280f945d6d8188af5817ae44723d6e1d
Author: Luca Bruno <lethalman88@gmail.com>
Date:   Tue Jun 1 22:06:17 2010 +0200

    Deprecate use of += and -= for signals
    
    The connect/disconnect methods should be used instead.
    
    Fixes bug 617571.