QIODevicePrivate: rearrange class members

As this class is a subject of the library hook data, there must be a
solid understanding of the member's alignment and padding across
different architectures. By reordering the layout, this patch provides
a clearer way of adding new members to the class.

Bump the TypeInformationVersion field in qtHookData, to notify the
Qt Creator developers that the offset of QFilePrivate::fileName was
changed and dumpers should be adapted.

Change-Id: Ied8b69bdeb9da50ff05aba2107bc75509674b18e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Alex Trotsenko 2020-08-21 18:04:19 +03:00
parent b3310426b6
commit 556a7e7318
4 changed files with 29 additions and 39 deletions

View File

@ -67,7 +67,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = {
// The required sizes and offsets are tested in tests/auto/other/toolsupport.
// When this fails and the change was intentional, adjust the test and
// adjust this value here.
19
20
};
static_assert(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0]));

View File

@ -156,22 +156,6 @@ static void checkWarnMessage(const QIODevice *device, const char *function, cons
\internal
*/
QIODevicePrivate::QIODevicePrivate()
: openMode(QIODevice::NotOpen),
pos(0), devicePos(0),
transactionPos(0),
readChannelCount(0),
writeChannelCount(0),
currentReadChannel(0),
currentWriteChannel(0),
readBufferChunkSize(QIODEVICE_BUFFERSIZE),
writeBufferChunkSize(0),
currentWriteChunk(nullptr),
transactionStarted(false)
, baseReadLineDataCalled(false)
, accessMode(Unset)
#ifdef QT_NO_QOBJECT
, q_ptr(nullptr)
#endif
{
}

View File

@ -80,11 +80,14 @@ public:
QIODevicePrivate();
virtual ~QIODevicePrivate();
QIODevice::OpenMode openMode;
QString errorString;
QList<QRingBuffer> readBuffers;
QList<QRingBuffer> writeBuffers;
// The size of this class is a subject of the library hook data.
// When adding a new member, do not make gaps and be aware
// about the padding. Accordingly, adjust offsets in
// tests/auto/other/toolsupport and bump the TypeInformationVersion
// field in src/corelib/global/qhooks.cpp, to notify the developers.
qint64 pos = 0;
qint64 devicePos = 0;
qint64 transactionPos = 0;
class QRingBufferRef {
QRingBuffer *m_buf;
@ -122,27 +125,30 @@ public:
QRingBufferRef buffer;
QRingBufferRef writeBuffer;
qint64 pos;
qint64 devicePos;
qint64 transactionPos;
int readChannelCount;
int writeChannelCount;
int currentReadChannel;
int currentWriteChannel;
int readBufferChunkSize;
int writeBufferChunkSize;
const QByteArray *currentWriteChunk;
bool transactionStarted;
bool baseReadLineDataCalled;
const QByteArray *currentWriteChunk = nullptr;
int readChannelCount = 0;
int writeChannelCount = 0;
int currentReadChannel = 0;
int currentWriteChannel = 0;
int readBufferChunkSize = QIODEVICE_BUFFERSIZE;
int writeBufferChunkSize = 0;
QList<QRingBuffer> readBuffers;
QList<QRingBuffer> writeBuffers;
QString errorString;
QIODevice::OpenMode openMode = QIODevice::NotOpen;
bool transactionStarted = false;
bool baseReadLineDataCalled = false;
virtual bool putCharHelper(char c);
enum AccessMode {
enum AccessMode : quint8 {
Unset,
Sequential,
RandomAccess
};
mutable AccessMode accessMode;
mutable AccessMode accessMode = Unset;
inline bool isSequential() const
{
if (accessMode == Unset)
@ -179,7 +185,7 @@ public:
void write(const char *data, qint64 size);
#ifdef QT_NO_QOBJECT
QIODevice *q_ptr;
QIODevice *q_ptr = nullptr;
#endif
};

View File

@ -126,9 +126,9 @@ void tst_toolsupport::offsets_data()
#ifdef Q_PROCESSOR_X86
// x86 32-bit has weird alignment rules. Refer to QtPrivate::AlignOf in
// qglobal.h for more details.
data << 188 << 296;
data << 180 << 288;
#else
data << 192 << 296;
data << 184 << 288;
#endif
}
#endif