Re: [Vala] Bug: badly crafted closures in delegates with default values
- From: Javier Casas Velasco <javier cv proximasystems net>
- To: vala-list gnome org
- Subject: Re: [Vala] Bug: badly crafted closures in delegates with default values
- Date: Wed, 05 Sep 2012 13:47:30 +0200
Sorry, something broke along the way.
Here is (i hope) in plaintext:
Good morning everyone.
I have found a bug in Vala.
If you declare a delegate with a default value, the closure for that
default value is broken. See this code:
class Test_delegates : Object {
public delegate string delegateType1(string param);
public delegateType1 mydelegate=defaultfun; //This default
initialization is badly made. The closure does not include the current
instance of Test_delegates
public Test_delegates(){
//mydelegate = defaultfun; //This initialization works.
Uncomment to see it working.
}
public string defaultfun(string param){
stdout.printf("defaultfun received %s\n", param);
string retorno = "### %s ###".printf(param);
stdout.printf("defaultfun returns %s\n", retorno);
return retorno;
}
public string otherfun(string param){
stdout.printf("otherfun received %s\n", param);
string retorno = "@@@ %s @@@".printf(param);
stdout.printf("otherfun returns %s\n", retorno);
return retorno;
}
public void run(){
string result = mydelegate("blebleble");
stderr.flush();
stdout.printf("mydelegate returned %s\n", result);
mydelegate=otherfun;
result = mydelegate("blebleble");
stdout.printf("mydelegate returned %s\n", result);
}
}
void main(){
var t1=new Test_delegates();
t1.run();
}
Shows:
** (process:8090): CRITICAL **: test_delegates_defaultfun: assertion
`self != NULL' failed
Tested with Vala 0.17.5.
Best regards,
Javier
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]