On Thursday, 20 June 2013 13:57:20 CEST, Pali Rohár wrote:
And is needed default constructor for propagating parent?
AddressbookInterface(QObject * parent) : QObject(parent) {}

Yes -- constructors aren't propagated, so you still need one.

I disagree with Thomas on the destructor, though. In the Itanium ABI (as used on e.g. x64_64 Linux 
for C++), the vtable (and therefore the information used for RTTI) is emitted at the time the first 
virtual method is defined. With QObject (and similarly with many other class hierarchies), the 
first one is destructor, and "defined" refers to the place where the body of this 
funciton appears. If it's in a header file, you'll get multiple instances of that and rely on 
linker to do the "right thing" when merging them.

What does it mean? It could lead to situations where dynamic_cast "doesn't  
work" (see [1], for example). Yes, Qt sort-of-kinda-solves this via qobject_cast, 
but that's a band aid. The lesson I've learned is to never use an inlined virtual 
destructor.

Cheers,
Jan

[1] 
http://stackoverflow.com/questions/1819114/when-can-typeid-return-different-type-info-instances-for-same-type

--
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/

Reply via email to