qt5base-lts/tests/auto/corelib/kernel
Kent Hansen 9e92ecde74 Provide API for "placement new" construction of meta-types
By making it possible to specify the place in memory where a
type should be constructed, any meta-type can be allocated on
the stack, for example. In the QML/JS QObject binding, this
makes it possible to call slots and access properties from
JavaScript without having to perform any mallocs (e.g. due to
QVariant creation) in the C++ <--> JS value conversion, in
the best case.

In addition to QMetaType::construct() and QMetaType::destruct(),
this change introduces QMetaType::typeSize(), which returns the
size of a type in bytes. This can be used to prepare a suitable
buffer for constructing a type using construct().

Benchmarks indicate that in-place construction is 2-5x faster
than normal construction for core and GUI types on linux-g++.

Note that there is already a QMetaType::construct() function
in Qt 4, which has been renamed to QMetaType::create() in Qt 5.
In order to avoid existing usages of construct() in user code
to call the Qt 5 construct() (when they really meant to call
create()), the third argument ("copy") of construct() is made
mandatory. Hence, calls to QMetaType::construct() written for
Qt 4 will cause a compile error when compiled with Qt 5, and
the user must adapt his code.

Task-number: QTBUG-12574
Change-Id: I836f06f6ee1c1c3edbd199a03424c78c942bdd3e
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
2011-10-19 10:25:28 +02:00
..
qabstractitemmodel Moving relevant tests to corelib/kernel 2011-09-01 12:42:14 +02:00
qcoreapplication Move handling of -qmljsdebugger argument to QCoreApplication 2011-09-19 16:37:51 +02:00
qeventloop Remove DEPENDS_ON from qtestlib API. 2011-10-19 07:24:13 +02:00
qitemmodel Remove Symbian-specific code from tests. 2011-09-29 06:41:42 +02:00
qmath Moving relevant tests to corelib/kernel 2011-09-01 12:42:14 +02:00
qmetaobject Moving relevant tests to corelib/kernel 2011-09-01 12:42:14 +02:00
qmetaproperty Moving relevant tests to corelib/kernel 2011-09-01 12:42:14 +02:00
qmetatype Provide API for "placement new" construction of meta-types 2011-10-19 10:25:28 +02:00
qmimedata Moving relevant tests to corelib/kernel 2011-09-01 12:42:14 +02:00
qobject Avoid using QSKIP in lieu of compile-time checks 2011-10-05 03:04:31 +02:00
qpointer Moving relevant tests to corelib/kernel 2011-09-01 12:42:14 +02:00
qsignalmapper Moving relevant tests to corelib/kernel 2011-09-01 12:42:14 +02:00
qsocketnotifier Avoid using QSKIP in lieu of compile-time checks 2011-10-05 03:04:31 +02:00
qtimer Move QTRY_VERIFY/QTRY_COMPARE into testlib. 2011-10-19 07:23:44 +02:00
qtipc Avoid using QSKIP in lieu of compile-time checks 2011-10-07 04:30:30 +02:00
qtranslator test: Re-enabled `tst_qtranslator' test that is now passing on Linux 2011-10-03 05:58:25 +02:00
qvariant Small re-factor of QVariant autotest. 2011-10-14 13:13:01 +02:00
qwineventnotifier Don't build empty qwineventnotifier test. 2011-10-17 03:30:55 +02:00
kernel.pro Don't build empty qwineventnotifier test. 2011-10-17 03:30:55 +02:00