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 604781 - Variables of delegate type cannot be connected to signals
Variables of delegate type cannot be connected to signals
Status: RESOLVED DUPLICATE of bug 787521
Product: vala
Classification: Core
Component: Delegates
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
: 624902 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-12-16 22:24 UTC by Benjamin Herr
Modified: 2018-02-13 22:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Connecting signal handler gives more-or-less unexpected error (174 bytes, text/plain)
2009-12-16 22:24 UTC, Benjamin Herr
Details

Description Benjamin Herr 2009-12-16 22:24:45 UTC
Created attachment 149879 [details]
Connecting signal handler gives more-or-less unexpected error

Trying to use a variable of a delegate type as opposed to a function, method or lambda as the argument to a signal's connect() call causes an error like

error: Argument 1: Cannot convert from `SignalHandler' to `Foo.sig'
Comment 1 Duncan Mac-Vicar P. 2011-05-12 21:44:09 UTC
Duplicate of 624902?
Comment 2 Luca Bruno 2011-05-13 10:46:47 UTC
*** Bug 624902 has been marked as a duplicate of this bug. ***
Comment 3 Al Thomas 2018-01-19 18:54:15 UTC
(In reply to Benjamin Herr from comment #0)
> Trying to use a variable of a delegate type as opposed to a function, method
> or lambda as the argument to a signal's connect() call causes an error like
> 
> error: Argument 1: Cannot convert from `SignalHandler' to `Foo.sig'

This error no longer occurs when compiled with 0.39.5. The given sample gives the error "Access to private member `Foo.sig' denied", but the following code compiles and runs:

class Foo {
  internal signal void sig ();
}

delegate void SignalHandler ();

void main () {
  Foo f = new Foo ();
  SignalHandler h = () => { print ("signal handler 'h' called\n"); };
  f.sig.connect (h);
  f.sig ();
}

I assume this was fixed by https://bugzilla.gnome.org/show_bug.cgi?id=787521 

There is a Vala warning though: "connect_delegate_to_signal.vala:10.18-10.18: warning: copying delegates is not supported"

There is also a C warning:
connect_delegate_to_signal.vala.c:44:1: warning: parameter names (without types) in function declaration
 typedef void (*sig(null)) (void* user_data);
Comment 4 Rico Tzschichholz 2018-02-13 22:09:10 UTC
> There is also a C warning:
> connect_delegate_to_signal.vala.c:44:1: warning: parameter names (without
> types) in function declaration
>  typedef void (*sig(null)) (void* user_data);

This was fixed in https://git.gnome.org/browse/vala/commit/?id=26ddc749ed5dc9d5953ce5e17eeab496e8ee467d
Comment 5 Rico Tzschichholz 2018-02-13 22:10:44 UTC

*** This bug has been marked as a duplicate of bug 787521 ***