Vala interface madness

Gergely Polonkai
Feb 26, 2016 :: 13:07

Although I have just started making it in C, I decided to move my Matrix GLib SDK to Vala. First to learn a new language, and second because it is much easier to write GObject based stuff with it.

For the first step I created a .vapi file from my existing sources, so the whole SDK prototype was available for me in Vala.

I had a MatrixEvent class that implemented the GInitable interface, and many others were subclassed MatrixEvent. For some reason I don’t remember, I created the following header for one of the event classes:

public class MatrixPresenceEvent : GLib.Object, GLib.Initable {

This is nice and everything, but as I didn’t create an init() method for MatrixPresenceEvent, it tried to use the one from the parent class and somehow got into an infinite loop. The Vala transformer (valac), however, doesn’t mention this.

Lessons learned: if you implement an interface on a subclass that is implemented by the parent don’t forget to add the necessary functions to the subclass.

comments powered by Disqus

Gergely Polonkai is a systems engineer of a telco company, and also a freelancer self- and software developer.

He is learning about different IT subjects since the late 1990s. These include web development, application building, systems engineering, IT security and many others. He also dug his nose deeply into free software, dealing with different types of Linux and its applications, while also writing and contributing to some open source projects.

On this site he is writing posts about different stuff he faces during work (oh my, yet another IT solutions blog), hoping they can help others with their job, or just to get along with their brand new netbook that shipped with Linux.

“I believe one can only achieve success if they follow their own instincts and listen to, but not bend under others’ opinions. If you change your course just because someone says so, you are following their instincts, not yours.”