diff options
author | Jędrzej Nowacki <jedrzej.nowacki@nokia.com> | 2011-10-12 17:32:26 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-09 10:11:34 +0100 |
commit | 8fd64d22ac7892b061a09c42c72aacf033b80876 (patch) | |
tree | 9c0d04049188ad5ff726419279ee88c3fdd0d1bf /tests/auto/testlib/selftests | |
parent | 2b39be6dd5d111482e5df06ac6dea18ca338d9f0 (diff) |
Make usage of internal QVariant space.
Each QVariant instance has internal storage which may be
used for well-know basic types. This patch changes the
behavior by delegating type dependent operation to QMetaType
class which knows more types than QVariant itself.
The patch significantly reduce amount of code in QVariant
implementation.
There are few side effects of this patch:
- better performance:
* for Core types when using Gui (QGuiVariant is able to
construct Core types)
* for small custom types (QVariant::Private::Data is used for all
types that has size small enough)
- comparing two QVariants can give different result for small custom
types (binary comparison instead of pointer comparison)
Change-Id: Ic17fa500d6a882110bfba896fd456c8e6c7a63a9
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/testlib/selftests')
-rw-r--r-- | tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 4d38aa1646..70396a75b3 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -80,8 +80,10 @@ void tst_Cmptest::compare_pointerfuncs() Q_DECLARE_METATYPE(QVariant) -class PhonyClass -{}; +struct PhonyClass +{ + int i; +}; void tst_Cmptest::compare_tostring_data() { @@ -108,9 +110,11 @@ void tst_Cmptest::compare_tostring_data() << QVariant(QVariant::Type(qRegisterMetaType<PhonyClass>("PhonyClass"))) ; + PhonyClass fake1 = {1}; + PhonyClass fake2 = {2}; QTest::newRow("both non-null user type") - << QVariant(qRegisterMetaType<PhonyClass>("PhonyClass"), (const void*)0) - << QVariant(qRegisterMetaType<PhonyClass>("PhonyClass"), (const void*)0) + << QVariant(qRegisterMetaType<PhonyClass>("PhonyClass"), (const void*)&fake1) + << QVariant(qRegisterMetaType<PhonyClass>("PhonyClass"), (const void*)&fake2) ; } |