summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2025-07-23 10:44:53 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2025-07-24 19:54:15 +0200
commit13cb9b8a596cf796e5b2374c3984fa251e98b850 (patch)
treed57c8801808c104143199eaaa1bb5057bca3a003 /src/corelib/kernel/qobject.cpp
parentd98fd12ca8a21c05d4aadc201d0f58ca6860463b (diff)
QQueuedMetaCallEvent: move allocArgs() call into copyArgValues()
The two functions are always called together from the constructors, first one and then the other. Calling copyArgValues() without calling allocArgs() first makes no sense. So move the allocArgs() call into copyArgValues(), and move the code next to each other. Amends f6211c079fa000c0d46b7912341f014669fa628a. Change-Id: Ib9c38509eb2c48dc314b95bd5300997a75f56198 Reviewed-by: Aurélien Brooke <aurelien@bahiasoft.fr> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r--src/corelib/kernel/qobject.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 0758f91ebfd..af39037a074 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -483,22 +483,6 @@ QAbstractMetaCallEvent::~QAbstractMetaCallEvent()
/*!
\internal
- */
-inline void QQueuedMetaCallEvent::allocArgs()
-{
- if (!d.nargs_)
- return;
-
- constexpr size_t each = sizeof(void*) + sizeof(QMetaType);
- void *const memory = d.nargs_ * each > sizeof(prealloc_) ?
- calloc(d.nargs_, each) : prealloc_;
-
- Q_CHECK_PTR(memory);
- d.args_ = static_cast<void **>(memory);
-}
-
-/*!
- \internal
Used for blocking queued connections, just passes \a args through without
allocating any memory.
@@ -580,7 +564,6 @@ QQueuedMetaCallEvent::QQueuedMetaCallEvent(ushort method_offset, ushort method_r
method_offset, method_relative}),
prealloc_()
{
- allocArgs();
copyArgValues(argCount, argTypes, argValues);
}
@@ -599,7 +582,6 @@ QQueuedMetaCallEvent::QQueuedMetaCallEvent(QtPrivate::QSlotObjectBase *slotObj,
{
if (d.slotObj_)
d.slotObj_->ref();
- allocArgs();
copyArgValues(argCount, argTypes, argValues);
}
@@ -616,7 +598,6 @@ QQueuedMetaCallEvent::QQueuedMetaCallEvent(QtPrivate::SlotObjUniquePtr slotObj,
0, ushort(-1)}),
prealloc_()
{
- allocArgs();
copyArgValues(argCount, argTypes, argValues);
}
@@ -648,9 +629,26 @@ QQueuedMetaCallEvent::~QQueuedMetaCallEvent()
/*!
\internal
*/
+inline void QQueuedMetaCallEvent::allocArgs()
+{
+ if (!d.nargs_)
+ return;
+
+ constexpr size_t each = sizeof(void*) + sizeof(QMetaType);
+ void *const memory = d.nargs_ * each > sizeof(prealloc_) ?
+ calloc(d.nargs_, each) : prealloc_;
+
+ Q_CHECK_PTR(memory);
+ d.args_ = static_cast<void **>(memory);
+}
+
+/*!
+ \internal
+ */
inline void QQueuedMetaCallEvent::copyArgValues(int argCount, const QtPrivate::QMetaTypeInterface * const *argTypes,
const void * const *argValues)
{
+ allocArgs();
void **args = d.args_;
QMetaType *types = reinterpret_cast<QMetaType *>(d.args_ + d.nargs_);
int inplaceIndex = 0;