From f4ebb061899da67aa26c08516fa7ee8c7b11dcbf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 12 Sep 2013 14:32:52 -0700 Subject: Remove Q_PACKED from structures that do not need to be packed These structures do not need to be packed. With some compilers, Q_PACKED was defined to be empty, which means that the code was working fine without packing. Or there were some lingering problems on those platforms (MSVC) and we're now exposing them in all platforms. Actually, it shouldn't be a problem anywhere. QCharAttributes, quint24 and QFontEngineQPA::Glyph have only char/uchar members, so they're packed already (they have alignof == 1). The only platform where that wasn't true was ARM OABI, which we don't support anymore. QFontEngineQPA::Header seems to always come from a QByteArray, so it doesn't neeed to be packed either. However, just to be sure, I'm inserting a check for alignment. And QFontEngineQPA::Block isn't used anywhere. Change-Id: Iacfa25edf336ef2a03aeb6e40ae90937a21661ae Reviewed-by: Konstantin Ritt Reviewed-by: Gunnar Sletta --- src/corelib/tools/qunicodetools_p.h | 2 +- src/gui/painting/qdrawhelper_p.h | 2 +- src/gui/text/qfontengine_qpa.cpp | 1 + src/gui/text/qfontengine_qpa_p.h | 6 +++--- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qunicodetools_p.h b/src/corelib/tools/qunicodetools_p.h index 5db3126159..8201861a43 100644 --- a/src/corelib/tools/qunicodetools_p.h +++ b/src/corelib/tools/qunicodetools_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -struct Q_PACKED QCharAttributes +struct QCharAttributes { uchar graphemeBoundary : 1; uchar wordBreak : 1; diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index f4c29996b4..418294c56d 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -702,7 +702,7 @@ struct quint24 { quint24(uint value); operator uint() const; uchar data[3]; -} Q_PACKED; +}; inline quint24::quint24(uint value) { diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp index 9b21d61aad..28b95bd509 100644 --- a/src/gui/text/qfontengine_qpa.cpp +++ b/src/gui/text/qfontengine_qpa.cpp @@ -169,6 +169,7 @@ const QFontEngineQPA::Glyph *QFontEngineQPA::findGlyph(glyph_t g) const bool QFontEngineQPA::verifyHeader(const uchar *data, int size) { + VERIFY(quintptr(data) % Q_ALIGNOF(Header) == 0); VERIFY(size >= int(sizeof(Header))); const Header *header = reinterpret_cast(data); if (header->magic[0] != 'Q' diff --git a/src/gui/text/qfontengine_qpa_p.h b/src/gui/text/qfontengine_qpa_p.h index 5fbdafdf56..c8b40abd7f 100644 --- a/src/gui/text/qfontengine_qpa_p.h +++ b/src/gui/text/qfontengine_qpa_p.h @@ -131,7 +131,7 @@ public: GlyphBlock }; - struct Q_PACKED Header + struct Header { char magic[4]; // 'QPF2' quint32 lock; // values: 0 = unlocked, 0xffffffff = read-only, otherwise qws client id of locking process @@ -140,14 +140,14 @@ public: quint16 dataSize; }; - struct Q_PACKED Block + struct Block { quint16 tag; quint16 pad; quint32 dataSize; }; - struct Q_PACKED Glyph + struct Glyph { quint8 width; quint8 height; diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 3a5e890076..123f049e34 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -2561,7 +2561,7 @@ public: } uchar data[3]; -} Q_PACKED; +}; void tst_QPainter::drawhelper_blend_color() { -- cgit v1.2.3