Vala Tip: Don’t add an already implemented interface to a derived class

While implementing GSVG, I had to add DomDocumentType to a DomDocument, so your renderer will recognize it is a SVG document, so I use following:

class GomNode : DomNode

class GomDocumentType : GomNode, DomNode

Note GomNode is implementing DomNode, so yo don’t need to add that interface in its derived classes GomDocumentType.

Hours after a set of debugs, I found you should don’t do that, because it produce a infinite cycle, leading to a crash.

So, your GomDocumentType should be:

class GomDocumentType : GomNode

Now GomDocumentType is a DomNode too.

Author: despinosa

Linux and GNOME user, full time, since 2001. Actual maintainer of GXml and contributor to other projects mainly on GObject Introspection support.

3 thoughts on “Vala Tip: Don’t add an already implemented interface to a derived class”

    1. At the end, it is. Unlike C/GObject, Vala rise errors on unimplemented methods or interfaces declared as prerequisites. This is a programming error and the compiler could help, by detecting if the classes, the new class derives from, have implemented an interface to rise an error.

Comments are closed.

Leave a Reply to despinosa Cancel reply

Your email address will not be published. Required fields are marked *