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 773661 - Object-style construction does not set property default values on construct properties
Object-style construction does not set property default values on construct p...
Status: RESOLVED DUPLICATE of bug 734013
Product: vala
Classification: Core
Component: Code Generator: GObject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2016-10-29 08:46 UTC by Jens Georg
Modified: 2016-11-28 21:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Minimal test case (1.51 KB, patch)
2016-11-04 19:03 UTC, Andrea Del Signore
none Details | Review
Proposed patch (1.71 KB, patch)
2016-11-04 19:04 UTC, Andrea Del Signore
none Details | Review

Description Jens Georg 2016-10-29 08:46:11 UTC
class Default : Object {                                                        
    public string default_id { owned get; construct; default = "default"; }     
    public int val { get; construct; }                                          
}                                                                               
                                                                                
class Derived : Default {                                                       
    public Derived() {                                                          
        Object (val: -1);                                                       
    }                                                                           
                                                                                
    public void do_something () {                                               
        print ("Default: %s\n", this.default_id);                               
    }                                                                           
}                                                                               
                                                                                
int main (string[] args) {                                                      
    var d = new Derived ();                                                     
                                                                                
    d.do_something ();                                                          
                                                                                
    return 0;                                                                   
}          

Output:
 ./default 
Default: (null)
Comment 1 Jens Georg 2016-10-29 08:56:54 UTC
"Issue" is that the default properties are set in instance_init and not as part of the param spec of that property. The construct properties are set after instance init and their default overwrites the value set in instance_init
Comment 2 Andrea Del Signore 2016-11-04 19:03:35 UTC
Created attachment 339135 [details] [review]
Minimal test case
Comment 3 Andrea Del Signore 2016-11-04 19:04:08 UTC
Created attachment 339136 [details] [review]
Proposed patch
Comment 4 Rico Tzschichholz 2016-11-04 19:35:39 UTC
Similar problem: https://bugzilla.gnome.org/show_bug.cgi?id=734013
Comment 5 Jens Georg 2016-11-04 23:23:15 UTC
Actually I'd say it's the same issue
Comment 6 Andrea Del Signore 2016-11-06 10:39:47 UTC
It's really the same and the proposed approach is better than mine.

This evening I'll try to see if patch still applies to master and what's the result for some corner cases.
Comment 7 Al Thomas 2016-11-28 21:35:43 UTC

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