summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2020-08-21 18:04:19 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2020-08-24 14:50:56 +0300
commit556a7e7318fce42e154439dd7157f44551a7f1ae (patch)
tree4eae631a431e59c5ffc1f014a87931a55ccdbf31
parentb3310426b6ae09fd9aba4183e60c7b88b837e735 (diff)
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>
-rw-r--r--src/corelib/global/qhooks.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp16
-rw-r--r--src/corelib/io/qiodevice_p.h46
-rw-r--r--tests/auto/other/toolsupport/tst_toolsupport.cpp4
4 files changed, 29 insertions, 39 deletions
diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp
index 5a0caa2ed0..c3a625bb5f 100644
--- a/src/corelib/global/qhooks.cpp
+++ b/src/corelib/global/qhooks.cpp
@@ -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]));
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index b920fbb17b..d64c2f37cb 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -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
{
}
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index a485ec43b3..8113f08237 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -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
};
diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp
index fc3a13267e..52fa821be7 100644
--- a/tests/auto/other/toolsupport/tst_toolsupport.cpp
+++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp
@@ -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