[Development] QtMultimedia BIC / header cleanliness issue

Sascha Cunz sascha-ml at babbelbox.org
Mon Dec 24 06:30:58 CET 2012

On Saturday, December 22, 2012 09:13:05 PM Thiago Macieira wrote:
> On domingo, 23 de dezembro de 2012 11.50.18, Sze Howe Koh wrote:
> > For consistency with the other interfaces, I suggest simply adding
> > empty virtual destructors. I believe this won't break any existing
> > code; the only code that should be affected is deletion via pointers
> > to QMediaServiceProviderFactoryInterface/QAudioSystemFactoryInterface.
> > But in this case, our change would probably fix memory leaks for
> > programs which use such code.
> Adding a new virtual implies changing the layout of the virtual table. If we
> append the virtual, the order of the existing virtuals should not change,
> so the calls should still make through.

Given the two classes:

class A {
public: virtual void a();

class B : public A {
public: virtual void b();

You're effectively saying here that adding a virtual to A doesn't change the 
v-table layout of A (which by itself is right), but it implicitly changes the 
v-table layout of B (B::b()'s address-slot moves one slot behind).

The above could happen, if someone doesn't inherit the interface directly. 

> Since the virtual destructor is missing, one can assume that objects of
> those classes are never deleted through those specific classes anyway.
> Moreover, it seems that those classes are often used in multiple
> inheritance and are not in the primary inheritance path. That means the
> addition of virtuals will not change the primary virtual table.

What is the effect to:

class UserClass : public QObject, WhereVTableWouldBeExpanded, AnotherInterface 

I think to remember to see that compilers produce code that expects the vtable 
of subobjects at a fixed offset from the beginning of the overall vtable.

Further someone might be keen enough to use virtual-inheritance with 

> So the question is: is the binary-incompatible change acceptable?

As for how those interfaces are _meant to be used_, i would personally say: 
just go ahead and break BC - In the usual case it doesn't matter.

But strictly spoken, I would rather say no: BC is BC no matter what silly 
mistakes it includes (I have actually had to deal with code that used the 
above mentioned inheritance layouts).
OTOH, it's still very early in the life of released Qt5.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121224/876ced88/attachment.html>

More information about the Development mailing list