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 557390 - Derived classes from compact one don't chain up instance init / instance finalize function
Derived classes from compact one don't chain up instance init / instance fina...
Status: RESOLVED WONTFIX
Product: vala
Classification: Core
Component: Objects
0.4.x
Other All
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-10-22 12:12 UTC by Andrea Del Signore
Modified: 2009-09-17 11:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (3.10 KB, patch)
2008-10-22 12:18 UTC, Andrea Del Signore
reviewed Details | Review
Vala test code (527 bytes, text/plain)
2008-10-22 12:19 UTC, Andrea Del Signore
  Details

Description Andrea Del Signore 2008-10-22 12:12:23 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:
Comment 1 Andrea Del Signore 2008-10-22 12:18:32 UTC
Created attachment 121131 [details] [review]
Proposed patch

This simple patch fix the bug
Comment 2 Andrea Del Signore 2008-10-22 12:19:20 UTC
Created attachment 121132 [details]
Vala test code
Comment 3 Jürg Billeter 2008-12-15 22:05:19 UTC
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.
Comment 4 Jürg Billeter 2009-09-17 11:37:50 UTC
Support for derived compact classes without fields has been added in the meantime. If the derived class contains fields, valac reports an error.