diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-08-27 22:51:09 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-08-27 22:51:09 +0200 |
commit | 190fa97c83472863fd886e86f626ab8196ed51b3 (patch) | |
tree | 49edb9f6a41d6c999c9bb43ae28911a8e7212757 /src/tools/moc/generator.cpp | |
parent | 3aa163491c9c8f28c88ac87cafc6418f2c0e46c5 (diff) | |
parent | 5971e0918757737425151c39a5f81a238663a17a (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
examples/widgets/doc/src/addressbook-fr.qdoc
Change-Id: Id1196e8e0c6445f1616c3f29234c974d809f8e48
Diffstat (limited to 'src/tools/moc/generator.cpp')
-rw-r--r-- | src/tools/moc/generator.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 4757fdad93..50da6d2e54 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -184,6 +184,18 @@ bool Generator::registerableMetaType(const QByteArray &propertyType) return false; } +/* returns true if name and qualifiedName refers to the same name. + * If qualified name is "A::B::C", it returns true for "C", "B::C" or "A::B::C" */ +static bool qualifiedNameEquals(const QByteArray &qualifiedName, const QByteArray &name) +{ + if (qualifiedName == name) + return true; + int index = qualifiedName.indexOf("::"); + if (index == -1) + return false; + return qualifiedNameEquals(qualifiedName.mid(index+2), name); +} + void Generator::generateCode() { bool isQt = (cdef->classname == "Qt"); @@ -431,7 +443,7 @@ void Generator::generateCode() int s = p.type.lastIndexOf("::"); if (s > 0) { QByteArray scope = p.type.left(s); - if (scope != "Qt" && scope != cdef->classname && !extraList.contains(scope)) + if (scope != "Qt" && !qualifiedNameEquals(cdef->qualified, scope) && !extraList.contains(scope)) extraList += scope; } } @@ -446,7 +458,7 @@ void Generator::generateCode() int s = enumKey.lastIndexOf("::"); if (s > 0) { QByteArray scope = enumKey.left(s); - if (scope != "Qt" && scope != cdef->classname && !extraList.contains(scope)) + if (scope != "Qt" && !qualifiedNameEquals(cdef->qualified, scope) && !extraList.contains(scope)) extraList += scope; } } @@ -972,9 +984,9 @@ void Generator::generateMetacall() if (!p.notify.isEmpty() && p.notifyId != -1) { const FunctionDef &f = cdef->signalList.at(p.notifyId); if (f.arguments.size() == 0) - fprintf(out, " emit %s();\n", p.notify.constData()); + fprintf(out, " Q_EMIT %s();\n", p.notify.constData()); else if (f.arguments.size() == 1 && f.arguments.at(0).normalizedType == p.type) - fprintf(out, " emit %s(%s%s);\n", + fprintf(out, " Q_EMIT %s(%s%s);\n", p.notify.constData(), prefix.constData(), p.member.constData()); } fprintf(out, " }\n"); |