diff options
author | Aurélien Brooke <[email protected]> | 2025-05-23 20:19:43 +0200 |
---|---|---|
committer | Aurélien Brooke <[email protected]> | 2025-07-11 20:44:23 +0200 |
commit | f6211c079fa000c0d46b7912341f014669fa628a (patch) | |
tree | 84fb4988d0e03d76edded4b6f1068d8e017b5985 /doc/src/snippets/code/doc_src_qt4-mainwindow.cpp | |
parent | 54204fc7943ef91aa9b665b1287b870680697db4 (diff) |
Previously, all arguments for queued connections were heap-allocated via
QMetaType::create(), even for small types like int or QObject*. This
incurred many micro-allocations and led to inefficient cross-thread
memory ownership. Additionally, argument copying was the responsibility
of the caller after constructing the QMetaCallEvent, leading to code
duplication and potential misuse.
To fix this, this patch introduces QQueuedMetaCallEvent as a specialized
subclass of QMetaCallEvent, used exclusively for queued signal-slot
delivery. It supports in-place argument storage by preallocating space
for up to 3 argument values (plus 5 pointers and types), enabling copy-
construction directly within the event object for types that fit within
a 3 × sizeof(void*) buffer and are suitably aligned. Heap allocation via
QMetaType::create() is still used as a fallback for larger types.
Legacy QMetaCallEvent constructors and the args() and types() accessors
are marked deprecated and will be removed once the corresponding
qtdeclarative patch eliminates their usage. The prealloc_ member,
currently shared for transitional reasons, will also be moved into
QQueuedMetaCallEvent as part of that cleanup.
Amends b7d073e9905bf9812ba96cecdcf6871a95517d30.
Change-Id: Icb6c1544de193b3fe6311fe76eaf00cf501d8977
Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'doc/src/snippets/code/doc_src_qt4-mainwindow.cpp')
0 files changed, 0 insertions, 0 deletions