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
This commit is contained in:
parent
49c571ecaa
commit
0e1ab9e5ad
|
@ -25,9 +25,9 @@ bool DosQObjectImpl::emitSignal(QObject *emitter, const QString &name, const std
|
|||
|
||||
Q_ASSERT(name.toUtf8() == method.name());
|
||||
|
||||
std::vector<void *> arguments(args.size(), nullptr);
|
||||
auto func = [](const QVariant & arg) -> void * { return (void *)(&arg); };
|
||||
std::transform(args.begin(), args.end(), arguments.begin(), func);
|
||||
std::vector<void *> 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<void*>(args[i].constData()); // Extract inner void*
|
||||
QMetaObject::activate(emitter, method.methodIndex(), arguments.data());
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue