GNOME Bugzilla – Bug 557390
Derived classes from compact one don't chain up instance init / instance finalize function
Last modified: 2009-09-17 11:37:50 UTC
Please describe the problem: This has 2 conseguences: 1) Initialization of fields in the "super" class isn't performed 2) Finalization of fields in the "super" class isn't performed too, resulting in a possibly memory leak Steps to reproduce: $ cat cl.vala using GLib; namespace Leaks { [Compact] private class Super { public string super_field = "pippo"; } private class SubClass : Super { public string subclass_field = "pluto"; } private class SubSubClass : SubClass { public string subsubclass_field = "paperino"; } public static void main (string[] args) { var subsubclass = new SubSubClass (); print ("super: %s\nsubclass: %s\nsubsubclass: %s\n", subsubclass.super_field, subsubclass.subclass_field, subsubclass.subsubclass_field); return; } } $ valac cl.vala $ ./cl super: (null) subclass: (null) subsubclass: paperino $ Actual results: The output is wrong: super: (null) subclass: (null) subsubclass: paperino Expected results: this output: super: pippo subclass: pluto subsubclass: paperino Does this happen every time? yes Other information:
Created attachment 121131 [details] [review] Proposed patch This simple patch fix the bug
Created attachment 121132 [details] Vala test code
As mentioned in IRC some time ago, I'm currently not planning to extend compact class features beyond what bindings need. Vala users should never need to declare compact classes.
Support for derived compact classes without fields has been added in the meantime. If the derived class contains fields, valac reports an error.