diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2017-03-11 19:39:32 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2017-03-13 11:03:47 +0000 |
commit | 16d1ddfc42732afc6ba90df66042c7ff4be348c2 (patch) | |
tree | a6b21d1165f50d9ae7ce88bbb644b4f70fdc9caa /src/tools/moc/generator.cpp | |
parent | 0d287500be09c800fbcc8f04862d316075ced546 (diff) |
moc: Support signals that return movable-only type
By adding std::move where it makes sense.
This is not only good for move-only types, but for any type which
can be moved as it saves copies of the return value in any case.
[ChangeLog][moc] Move-only types are now supported as return types
of signals and slots.
Change-Id: Idc9453af993e7574a6bddd4a87210eddd3da48a9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/tools/moc/generator.cpp')
-rw-r--r-- | src/tools/moc/generator.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index db27067cf6..c4184929ef 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1193,7 +1193,7 @@ void Generator::generateStaticMetacall() } fprintf(out, ");"); if (f.normalizedType != "void") { - fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = _r; } ", + fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = std::move(_r); } ", noRef(f.normalizedType).constData()); isUsed_a = true; } @@ -1506,11 +1506,7 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, ")%s\n{\n", constQualifier); if (def->type.name.size() && def->normalizedType != "void") { QByteArray returnType = noRef(def->normalizedType); - if (returnType.endsWith('*')) { - fprintf(out, " %s _t0 = 0;\n", returnType.constData()); - } else { - fprintf(out, " %s _t0 = %s();\n", returnType.constData(), returnType.constData()); - } + fprintf(out, " %s _t0{};\n", returnType.constData()); } fprintf(out, " void *_a[] = { "); |