[Development] Adoption of virtual_hook()

Thiago Macieira thiago.macieira at intel.com
Wed Apr 11 15:09:40 CEST 2012


On quarta-feira, 11 de abril de 2012 12.12.23, lars.knoll at nokia.com wrote:
> I was never a really big fan of adding lots of virtual_hook()'s to
> classes. vtable entries do come at a cost and in many cases it's not
> really required. I am certainly against blindly adding them to all our
> classes.

In KDE 3, we added virtual_hook() everywhere.

In KDE 4, we removed from all classes deriving from QObject. qt_metacall is 
our virtual hook.

For non-QObject classes which *already* have virtual tables, we should 
consider it. Fortunately, those classes are minority in Qt, we have very few 
of them.

And by consider, I don't mean "definitely use". Take QEvent, for example: it's 
virtual, but it has barely any virtual functions. It's unlikely we'll need a 
virtual_hook in it.

(In fact, QEvent is really bad: it's a copyable polymorphic class)
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120411/dc25a5e9/attachment.sig>


More information about the Development mailing list