forked from qt-creator/qt-creator
Debugger: Adapted dumper auto tests to new QObjectPrivate changes.
Also added checks to guard against these kind of changes in the future.
This commit is contained in:
@@ -86,15 +86,36 @@ struct Connection
|
|||||||
int method;
|
int method;
|
||||||
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
|
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
|
||||||
QBasicAtomicPointer<int> argumentTypes;
|
QBasicAtomicPointer<int> argumentTypes;
|
||||||
|
Connection *nextConnectionList;
|
||||||
//senders linked list
|
//senders linked list
|
||||||
Connection *next;
|
Connection *next;
|
||||||
Connection **prev;
|
Connection **prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<Connection *> ConnectionList;
|
struct ConnectionList
|
||||||
|
{
|
||||||
|
ConnectionList() : first(0), last(0) { }
|
||||||
|
int size() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (Connection *c = first; c != 0; c = c->nextConnectionList)
|
||||||
|
++count;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
Connection *first;
|
||||||
|
Connection *last;
|
||||||
|
};
|
||||||
|
|
||||||
typedef Connection *SenderList;
|
typedef Connection *SenderList;
|
||||||
|
|
||||||
static inline const Connection &connectionAt(const ConnectionList &l, int i) { return *l.at(i); }
|
static inline const Connection &connectionAt(const ConnectionList &l, int i)
|
||||||
|
{
|
||||||
|
Connection *conn = l.first;
|
||||||
|
for (int cnt = 0; cnt < i; ++cnt)
|
||||||
|
conn = conn->nextConnectionList;
|
||||||
|
return *conn;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ObjectPrivate : public QObjectData
|
class ObjectPrivate : public QObjectData
|
||||||
@@ -130,7 +151,7 @@ public:
|
|||||||
void *currentChildBeingDeleted;
|
void *currentChildBeingDeleted;
|
||||||
void *declarativeData;
|
void *declarativeData;
|
||||||
void *objectGuards;
|
void *objectGuards;
|
||||||
QAtomicPointer<void> sharedRefCount;
|
QAtomicPointer<void> sharedRefcount;
|
||||||
int *deleteWatch;
|
int *deleteWatch;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -580,6 +580,33 @@ template <> const char *typeToNumchild(const QString &)
|
|||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int qobj_priv_conn_list_size(const QObjectPrivate::ConnectionList &l)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= 0x040600
|
||||||
|
int count = 0;
|
||||||
|
for (QObjectPrivate::Connection *c = l.first; c != 0; c = c->nextConnectionList)
|
||||||
|
++count;
|
||||||
|
return count;
|
||||||
|
#else
|
||||||
|
return l.size();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static QObjectPrivate::Connection &qobj_priv_conn_list_at(
|
||||||
|
const QObjectPrivate::ConnectionList &l, int pos)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= 0x040600
|
||||||
|
QObjectPrivate::Connection *c = l.first;
|
||||||
|
for (int i = 0; i < pos; ++i)
|
||||||
|
c = c->nextConnectionList;
|
||||||
|
return *c;
|
||||||
|
#else
|
||||||
|
return l.at(pos);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void tst_Debugger::dumpQAbstractItemHelper(QModelIndex &index)
|
void tst_Debugger::dumpQAbstractItemHelper(QModelIndex &index)
|
||||||
{
|
{
|
||||||
const QAbstractItemModel *model = index.model();
|
const QAbstractItemModel *model = index.model();
|
||||||
@@ -1592,8 +1619,9 @@ void tst_Debugger::dumpQObjectSignalHelper(QObject &o, int sigNum)
|
|||||||
QObjectPrivate::ConnectionList connList =
|
QObjectPrivate::ConnectionList connList =
|
||||||
connLists != 0 && connLists->size() > sigNum ?
|
connLists != 0 && connLists->size() > sigNum ?
|
||||||
connLists->at(sigNum) : QObjectPrivate::ConnectionList();
|
connLists->at(sigNum) : QObjectPrivate::ConnectionList();
|
||||||
for (int i = 0; i < connList.size(); ++i) {
|
int i = 0;
|
||||||
const QObjectPrivate::Connection *conn = connList.at(i);
|
for (QObjectPrivate::Connection *conn = connList.first; conn != 0;
|
||||||
|
++i, conn = conn->nextConnectionList) {
|
||||||
const QString iStr = QString::number(i);
|
const QString iStr = QString::number(i);
|
||||||
expected.append("{name='").append(iStr).append(" receiver',");
|
expected.append("{name='").append(iStr).append(" receiver',");
|
||||||
if (conn->receiver == &o)
|
if (conn->receiver == &o)
|
||||||
@@ -1615,10 +1643,10 @@ void tst_Debugger::dumpQObjectSignalHelper(QObject &o, int sigNum)
|
|||||||
expected.append("',numchild='0'},{name='").append(iStr).append(" type',type='',value='<").
|
expected.append("',numchild='0'},{name='").append(iStr).append(" type',type='',value='<").
|
||||||
append(connectionType(conn->connectionType)).append(" connection>',").
|
append(connectionType(conn->connectionType)).append(" connection>',").
|
||||||
append("numchild='0'}");
|
append("numchild='0'}");
|
||||||
if (i < connList.size() - 1)
|
if (conn != connList.last)
|
||||||
expected.append(",");
|
expected.append(",");
|
||||||
}
|
}
|
||||||
expected.append("],numchild='").append(QString::number(connList.size())).append("'");
|
expected.append("],numchild='").append(QString::number(i)).append("'");
|
||||||
#endif
|
#endif
|
||||||
testDumper(expected, &o, NS"QObjectSignal", true, "", "", sigNum);
|
testDumper(expected, &o, NS"QObjectSignal", true, "", "", sigNum);
|
||||||
}
|
}
|
||||||
@@ -1692,7 +1720,8 @@ void tst_Debugger::dumpQObjectSignalListHelper(QObject &o)
|
|||||||
connLists != 0 && connLists->size() > sigNum ?
|
connLists != 0 && connLists->size() > sigNum ?
|
||||||
connLists->at(sigNum) : QObjectPrivate::ConnectionList();
|
connLists->at(sigNum) : QObjectPrivate::ConnectionList();
|
||||||
expected.append("{name='").append(QString::number(sigNum)).append("',value='").
|
expected.append("{name='").append(QString::number(sigNum)).append("',value='").
|
||||||
append(signature).append("',numchild='").append(QString::number(connList.size())).
|
append(signature).append("',numchild='").
|
||||||
|
append(QString::number(qobj_priv_conn_list_size(connList))).
|
||||||
append("',addr='").append(addrString).append("',type='"NS"QObjectSignal'}");
|
append("',addr='").append(addrString).append("',type='"NS"QObjectSignal'}");
|
||||||
if (i < methods.size() - 1)
|
if (i < methods.size() - 1)
|
||||||
expected.append(",");
|
expected.append(",");
|
||||||
@@ -1755,8 +1784,10 @@ void tst_Debugger::dumpQObjectSlotHelper(QObject &o, int slot)
|
|||||||
const QObjectPrivate::ConnectionList &connList =
|
const QObjectPrivate::ConnectionList &connList =
|
||||||
connLists != 0 && connLists->size() > signal ?
|
connLists != 0 && connLists->size() > signal ?
|
||||||
connLists->at(signal) : QObjectPrivate::ConnectionList();
|
connLists->at(signal) : QObjectPrivate::ConnectionList();
|
||||||
for (int i = 0; i < connList.size(); ++i) {
|
const int listSize = qobj_priv_conn_list_size(connList);
|
||||||
const QObjectPrivate::Connection *conn = connList.at(i);
|
for (int i = 0; i < listSize; ++i) {
|
||||||
|
const QObjectPrivate::Connection *conn =
|
||||||
|
&qobj_priv_conn_list_at(connList, i);
|
||||||
if (conn->receiver == &o && conn->method == slot) {
|
if (conn->receiver == &o && conn->method == slot) {
|
||||||
++numChild;
|
++numChild;
|
||||||
const QMetaMethod &method = sender->metaObject()->method(signal);
|
const QMetaMethod &method = sender->metaObject()->method(signal);
|
||||||
@@ -1869,8 +1900,10 @@ void tst_Debugger::dumpQObjectSlotListHelper(QObject &o)
|
|||||||
const QObjectPrivate::ConnectionList &connList =
|
const QObjectPrivate::ConnectionList &connList =
|
||||||
connLists != 0 && connLists->size() > signal ?
|
connLists != 0 && connLists->size() > signal ?
|
||||||
connLists->at(signal) : QObjectPrivate::ConnectionList();
|
connLists->at(signal) : QObjectPrivate::ConnectionList();
|
||||||
for (int c = 0; c != connList.size(); ++c) {
|
const int listSize = qobj_priv_conn_list_size(connList);
|
||||||
const QObjectPrivate::Connection *conn = connList.at(c);
|
for (int c = 0; c != listSize; ++c) {
|
||||||
|
const QObjectPrivate::Connection *conn =
|
||||||
|
&qobj_priv_conn_list_at(connList, c);
|
||||||
if (conn->receiver == &o && conn->method == k)
|
if (conn->receiver == &o && conn->method == k)
|
||||||
++numChild;
|
++numChild;
|
||||||
}
|
}
|
||||||
@@ -2116,9 +2149,32 @@ void tst_Debugger::dumpQTextCodec()
|
|||||||
// Creator
|
// Creator
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#define VERIFY_OFFSETOF(member) \
|
||||||
|
do { \
|
||||||
|
QVERIFY(offsetof(QObjectPrivate, member) == offsetof(ObjectPrivate, member)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
void tst_Debugger::initTestCase()
|
void tst_Debugger::initTestCase()
|
||||||
{
|
{
|
||||||
QVERIFY(sizeof(QObjectPrivate) == sizeof(ObjectPrivate));
|
QVERIFY(sizeof(QObjectPrivate) == sizeof(ObjectPrivate));
|
||||||
|
VERIFY_OFFSETOF(threadData);
|
||||||
|
VERIFY_OFFSETOF(extraData);
|
||||||
|
VERIFY_OFFSETOF(objectName);
|
||||||
|
VERIFY_OFFSETOF(connectionLists);
|
||||||
|
VERIFY_OFFSETOF(senders);
|
||||||
|
VERIFY_OFFSETOF(currentSender);
|
||||||
|
VERIFY_OFFSETOF(eventFilters);
|
||||||
|
VERIFY_OFFSETOF(currentChildBeingDeleted);
|
||||||
|
VERIFY_OFFSETOF(connectedSignals);
|
||||||
|
VERIFY_OFFSETOF(deleteWatch);
|
||||||
|
#if QT_VERSION < 0x040600
|
||||||
|
VERIFY_OFFSETOF(pendingChildInsertedEvents);
|
||||||
|
#else
|
||||||
|
VERIFY_OFFSETOF(declarativeData);
|
||||||
|
VERIFY_OFFSETOF(objectGuards);
|
||||||
|
VERIFY_OFFSETOF(sharedRefcount);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_Debugger::readStandardOutput()
|
void tst_Debugger::readStandardOutput()
|
||||||
|
Reference in New Issue
Block a user