qt5base-lts/tests/auto/gui/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
..
qclipboard Avoid using QSKIP in lieu of compile-time checks 2011-10-03 03:34:57 +02:00
qdrag Moved gui autotests into new directory structure 2011-09-01 10:59:49 +02:00
qevent Moved gui autotests into new directory structure 2011-09-01 10:59:49 +02:00
qfileopenevent Remove Symbian-specific code from tests. 2011-09-29 06:41:42 +02:00
qguimetatype Provide API for "placement new" construction of meta-types 2011-10-19 10:25:28 +02:00
qguivariant Moved gui autotests into new directory structure 2011-09-01 10:59:49 +02:00
qinputpanel Move input panel visibility ownership from QInputPanel to QPlatformInputContext 2011-10-11 16:03:25 +02:00
qkeysequence Remove last remnants of symbian in autotests. 2011-10-06 01:27:58 +02:00
qmouseevent Moved gui autotests into new directory structure 2011-09-01 10:59:49 +02:00
qmouseevent_modal Moved gui autotests into new directory structure 2011-09-01 10:59:49 +02:00
qpalette Moved gui autotests into new directory structure 2011-09-01 10:59:49 +02:00
qshortcut Merge branch 'refactor' 2011-09-13 08:54:45 +02:00
qtouchevent Fix autotest gui/widgets dependencies 2011-09-19 10:24:25 +02:00
kernel.pro Add autotest for QMetaType creation of gui types 2011-10-14 14:46:35 +02:00