m_me = 0;
}
+CompletionRegisteringType *CompletionRegisteringType::m_me = 0;
+CompletionRegisteringType::CompletionRegisteringType()
+{
+}
+
+void CompletionRegisteringType::classBegin()
+{
+}
+
+void CompletionRegisteringType::componentComplete()
+{
+ m_me = this;
+}
+
+CompletionRegisteringType *CompletionRegisteringType::me()
+{
+ return m_me;
+}
+
+void CompletionRegisteringType::clearMe()
+{
+ m_me = 0;
+}
+
void registerTypes()
{
qmlRegisterType<SelfRegisteringType>("Qt.test", 1,0, "SelfRegistering");
+ qmlRegisterType<CompletionRegisteringType>("Qt.test", 1,0, "CompletionRegistering");
}
#define TESTTYPES_H
#include <QtCore/qobject.h>
+#include <QDeclarativeParserStatus>
class SelfRegisteringType : public QObject
{
int m_v;
};
+class CompletionRegisteringType : public QObject, public QDeclarativeParserStatus
+{
+Q_OBJECT
+public:
+ CompletionRegisteringType();
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+ static CompletionRegisteringType *me();
+ static void clearMe();
+
+private:
+ static CompletionRegisteringType *m_me;
+};
+
void registerTypes();
#endif // TESTTYPES_H
void noIncubationController();
void forceCompletion();
void setInitialState();
+ void clearDuringCompletion();
private:
QDeclarativeIncubationController controller;
}
}
+void tst_qdeclarativeincubator::clearDuringCompletion()
+{
+ CompletionRegisteringType::clearMe();
+ SelfRegisteringType::clearMe();
+
+ QDeclarativeComponent component(&engine, TEST_FILE("clearDuringCompletion.qml"));
+ QVERIFY(component.isReady());
+
+ QDeclarativeIncubator incubator;
+ component.create(incubator);
+
+ QCOMPARE(incubator.status(), QDeclarativeIncubator::Loading);
+ QVERIFY(CompletionRegisteringType::me() == 0);
+
+ while (CompletionRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(CompletionRegisteringType::me() != 0);
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ QPointer<QObject> srt = SelfRegisteringType::me();
+
+ incubator.clear();
+ QVERIFY(incubator.isNull());
+ QVERIFY(srt.isNull());
+}
+
QTEST_MAIN(tst_qdeclarativeincubator)
#include "tst_qdeclarativeincubator.moc"