diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-10-22 13:07:11 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-10-22 13:07:11 +0200 |
commit | b103f6a6b9cc0ddf3df2788816a6fd98369b1b6d (patch) | |
tree | fc90bc070f0f50a2d8768db8fa1e16611d158f18 /tests/auto/qml/qqmlecmascript | |
parent | 4867a49618e0d6a476e0549aeca5134b2e3c5892 (diff) | |
parent | 8ee3673e439b4499a8a4a4280637ee0270c4a54a (diff) |
Merge remote-tracking branch 'origin/5.6' into origin/dev
Conflicts:
src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.h
src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h
src/qml/debugger/qqmldebugserviceinterfaces.cpp
src/qml/jsruntime/qv4debugging_p.h
Change-Id: I82a4ce1bcd4579181df886558f55ad2b328d1682
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/singletonTest.qml | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/singletonTest2.qml | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.cpp | 33 |
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/singletonTest.qml b/tests/auto/qml/qqmlecmascript/data/singletonTest.qml index 9e41bd4e2c..ca3784322a 100644 --- a/tests/auto/qml/qqmlecmascript/data/singletonTest.qml +++ b/tests/auto/qml/qqmlecmascript/data/singletonTest.qml @@ -45,4 +45,5 @@ Item { property bool qobjectTest: MyInheritedQmlObjectSingleton.isItYouQObject(MyInheritedQmlObjectSingleton) property bool myQmlObjectTest: MyInheritedQmlObjectSingleton.isItYouMyQmlObject(MyInheritedQmlObjectSingleton) property bool myInheritedQmlObjectTest: MyInheritedQmlObjectSingleton.isItYouMyInheritedQmlObject(MyInheritedQmlObjectSingleton) + property int testFoo: TestTypeCppSingleton.foo } diff --git a/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml b/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml index 67654dd81f..ef08745812 100644 --- a/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml +++ b/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml @@ -52,6 +52,7 @@ Item { property bool qobjectTest2: false property bool qobjectTest3: false property bool singletonEqualToItself: true + property int testFoo: -1 Component.onCompleted: { MyInheritedQmlObjectSingleton.myInheritedQmlObjectProperty = MyInheritedQmlObjectSingleton; @@ -70,5 +71,6 @@ Item { qobjectTest3 = MyInheritedQmlObjectSingleton == MyInheritedQmlObjectSingleton.qobjectProperty; singletonEqualToItself = MyInheritedQmlObjectSingleton == MyInheritedQmlObjectSingleton; + testFoo = TestTypeCppSingleton.foo } } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index edfd97b750..285158a4ea 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -325,6 +325,38 @@ bool MyInheritedQmlObject::isItYouMyInheritedQmlObject(MyInheritedQmlObject *o) return o && o == theSingletonObject; } +class TestTypeCppSingleton : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo) + + Q_CLASSINFO("DefaultProperty", "foo") +public: + int foo() { return 0; } + static TestTypeCppSingleton *instance() { + static TestTypeCppSingleton cppSingleton; + return &cppSingleton; + } +private: + TestTypeCppSingleton(){} + ~TestTypeCppSingleton() { + // just to make sure it crashes on double delete + static int a = 0; + static int *ptr = &a; + *ptr = 1; + ptr = 0; + } +}; + +QObject *testTypeCppProvider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + TestTypeCppSingleton *o = TestTypeCppSingleton::instance(); + QQmlEngine::setObjectOwnership(o, QQmlEngine::CppOwnership); + return o; +} + static QObject *create_singletonWithEnum(QQmlEngine *, QJSEngine *) { return new SingletonWithEnum; @@ -391,6 +423,7 @@ void registerTypes() qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias"); qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject"); qmlRegisterSingletonType<MyInheritedQmlObject>("Test", 1, 0, "MyInheritedQmlObjectSingleton", inheritedQmlObject_provider); + qmlRegisterSingletonType<TestTypeCppSingleton>("Test", 1, 0, "TestTypeCppSingleton", testTypeCppProvider); qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject"); qmlRegisterType<MyVeryDeferredObject>("Qt.test", 1,0, "MyVeryDeferredObject"); qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer"); |