Add a qtHookData field for Qt Creator's data display

Qt Creator needs to be able to determine structure sizes and data
member offsets for certain private types even in the absence of debug
information.

It is sufficient to keep and test the actual data sets on the Qt Creator
side, as long library provides a hint which data set is needed.
So far, HookDataVersion was meant to be used for that purpose. To
make it more explicit, this patch introduce a TypeInformationVersion
field in qtHookData.

Change-Id: Ia1c3c6f62f314d63c4df289ef456f047c5e84cf4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
hjk 2015-08-31 08:48:49 +02:00
parent 51e501fa8d
commit 7b0e771ad7
4 changed files with 22 additions and 2 deletions

View File

@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE
// Only add to the end, and bump version if you do.
quintptr Q_CORE_EXPORT qtHookData[] = {
2, // hook data version
3, // hook data version
QHooks::LastHookIndex, // size of qtHookData
QT_VERSION,
@ -52,6 +52,15 @@ quintptr Q_CORE_EXPORT qtHookData[] = {
0,
// Startup, void(*)(), called once QCoreApplication is operational
0,
// TypeInformationVersion, an integral value, bumped whenever private
// object sizes or member offsets that are used in Qt Creator's
// data structure "pretty printing" change.
//
// 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.
0
};

View File

@ -50,6 +50,7 @@ enum HookIndex {
AddQObject = 3,
RemoveQObject = 4,
Startup = 5,
TypeInformationVersion = 6,
LastHookIndex
};

View File

@ -46,7 +46,7 @@ private slots:
void tst_QHooks::testVersion()
{
QVERIFY(qtHookData[QHooks::HookDataVersion] >= 1);
QVERIFY(qtHookData[QHooks::HookDataVersion] >= 3);
QCOMPARE(qtHookData[QHooks::HookDataSize], (quintptr)QHooks::LastHookIndex);
QCOMPARE(qtHookData[QHooks::QtVersion], (quintptr)QT_VERSION);
}

View File

@ -29,6 +29,16 @@
#include <QtTest>
//
// Note:
//
// When this test here fails and the change leading to the failure
// intentionally changed a private class, adjust the test here and bump
// the TypeInformationVersion field in src/corelib/global/qhooks.cpp
// in the same commit as the modification to the private class.
//
// Don't do this at home. This is test code, not production.
#define protected public
#define private public