Il 17/07/20 17:30, Thiago Macieira ha scritto:
I will give a +2 for this patch, since I prefer it. That means adding properties doesn't imply an extra 8 bytes per class in the hierarchy. Imagine a user class hierarcy like QSctpSocket -> QTcpSocket -> QAbstractSocket -> QIODevice -> QObject. If each class has properties, that adds 40 bytes to the full size of QSctpSocket.[Yes, I know Qt-based classes should just put their properties in the d pointer, but users don't usually have d pointers]
Even with d pointers, how is that supposed to work? You still need the dummy "property object" in the class where it's declared, right? That would still add 1 byte to the class, although that can be folded into the alignment.
What am I missing here?
class QObject { QObjectPrivate *d_ptr; public: virtual ~QObject(); union { P1 objectName; P2 somethingElse; }; };/* alignof == 8, sizeof == 24 (8 vptr + 8 d_ptr + 1 union + 7 padding) */class QWidget : public QObject /*, QPaintDevice, I know */ { public: union { P3 visible; P4 geometry; }; }; /* alignof == 8, sizeof still 24 (23 for the base class + 1 union + 6 padding) */
So in your example QSctpSocket would still be 24 bytes, because the inheritance is not deep enough to make sizeof 32?
Thanks, -- Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development