From 0e1ab9e5ad1bfa9c8e56da6c950cf92d0e24e1a1 Mon Sep 17 00:00:00 2001 From: Filippo Cucchetto Date: Sat, 9 Apr 2016 14:56:11 +0200 Subject: [PATCH] Fixed crashes on signal emittion This is caused by two bugs: 1) QMetaObject::activate first argument must be the return value 2) The next arguments should be void* to the actual datatype contained inside the QVariants and not QVariant*. In other words given "a" of type QVariant we should use a.constData() and not &a --- lib/src/DosQObjectImpl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/DosQObjectImpl.cpp b/lib/src/DosQObjectImpl.cpp index f8217df..b2308d1 100644 --- a/lib/src/DosQObjectImpl.cpp +++ b/lib/src/DosQObjectImpl.cpp @@ -25,9 +25,9 @@ bool DosQObjectImpl::emitSignal(QObject *emitter, const QString &name, const std Q_ASSERT(name.toUtf8() == method.name()); - std::vector arguments(args.size(), nullptr); - auto func = [](const QVariant & arg) -> void * { return (void *)(&arg); }; - std::transform(args.begin(), args.end(), arguments.begin(), func); + std::vector arguments(args.size() + 1, nullptr); // +1 for the result at pos 0 + for (size_t i = 0; i < args.size(); ++i) + arguments[i+1] = const_cast(args[i].constData()); // Extract inner void* QMetaObject::activate(emitter, method.methodIndex(), arguments.data()); return true; }