summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qobject
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-04-22 09:31:58 +0200
committerLiang Qi <liang.qi@qt.io>2016-04-25 14:03:45 +0200
commitbb4b86618dc930e0035c5829e336f2606d140ada (patch)
tree6e36808ca46244373bc70aabbb926cc114538beb /tests/auto/corelib/kernel/qobject
parent276adc5a09914fd89d976bb90cc0cd67de9d3d6e (diff)
parentbbd1228b17ee3f3a5483f88b0a581d6a60c41cad (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: config.tests/unix/compile.test configure src/android/jar/src/org/qtproject/qt5/android/QtMessageDialogHelper.java src/corelib/global/qglobal.cpp src/widgets/kernel/qapplication.cpp src/widgets/styles/qwindowsvistastyle.cpp tests/auto/corelib/kernel/qobject/tst_qobject.cpp Change-Id: I067083f34e5290aa5f7565e40c30a069cc37b83a
Diffstat (limited to 'tests/auto/corelib/kernel/qobject')
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 23f8ff5857..1902687eef 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -143,6 +143,7 @@ private slots:
void exceptions();
void noDeclarativeParentChangedOnDestruction();
void deleteLaterInAboutToBlockHandler();
+ void mutableFunctor();
};
struct QObjectCreatedOnShutdown
@@ -6512,6 +6513,24 @@ void tst_QObject::noDeclarativeParentChangedOnDestruction()
#endif
}
+struct MutableFunctor {
+ int count;
+ MutableFunctor() : count(0) {}
+ int operator()() { return ++count; }
+};
+
+void tst_QObject::mutableFunctor()
+{
+ ReturnValue o;
+ MutableFunctor functor;
+ QCOMPARE(functor.count, 0);
+ connect(&o, &ReturnValue::returnInt, functor);
+ QCOMPARE(emit o.returnInt(0), 1);
+ QCOMPARE(emit o.returnInt(0), 2); // each emit should increase the internal count
+
+ QCOMPARE(functor.count, 0); // but the original object should have been copied at connect time
+}
+
// Test for QtPrivate::HasQ_OBJECT_Macro
Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);