From 7c6b6876aa8841a56a6571c6a039c67a5d649bdb Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 5 May 2015 13:51:16 +0200 Subject: qdoc: Enable prepare-phase warnings in single-exec mode In single-exec mode, QDoc must never skip documentation warnings as there is no subsequent QDoc run to re-execute the same code paths (in generate phase) that generate warnings. Change-Id: I8da2f16cfb12b3b3509249d1c9941d63733176a9 Reviewed-by: Martin Smith --- src/tools/qdoc/location.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/tools') diff --git a/src/tools/qdoc/location.cpp b/src/tools/qdoc/location.cpp index 12dc9e1b4c..5eba2a69ef 100644 --- a/src/tools/qdoc/location.cpp +++ b/src/tools/qdoc/location.cpp @@ -256,7 +256,7 @@ QString Location::canonicalRelativePath(const QString &path) */ void Location::warning(const QString& message, const QString& details) const { - if (!Generator::preparing()) + if (!Generator::preparing() || Generator::singleExec()) emitMessage(Warning, message, details); } @@ -267,7 +267,7 @@ void Location::warning(const QString& message, const QString& details) const */ void Location::error(const QString& message, const QString& details) const { - if (!Generator::preparing()) + if (!Generator::preparing() || Generator::singleExec()) emitMessage(Error, message, details); } -- cgit v1.2.3 From d6efc6b543d1a8fe2e1232750a98e396db07be0f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 11 May 2015 12:52:34 +0200 Subject: moc: Fix type for gadget's CreateInstance metacall An error similar to the one below would be emitted by the compiler on the moc generated file: error: assigning to 'QObject *' from incompatible type 'Gadget *' if (_a[0]) *reinterpret_cast(_a[0]) = _r; } break; Change-Id: I75ae7bd6c46d20db2d47a80eaa08aae302d7d6c8 Reviewed-by: Simon Hausmann Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/generator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 8b6a0519c5..3b00e21208 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1125,7 +1125,8 @@ void Generator::generateStaticMetacall() fprintf(out, "%s", QByteArray("QPrivateSignal()").constData()); } fprintf(out, ");\n"); - fprintf(out, " if (_a[0]) *reinterpret_cast(_a[0]) = _r; } break;\n"); + fprintf(out, " if (_a[0]) *reinterpret_cast<%s**>(_a[0]) = _r; } break;\n", + cdef->hasQGadget ? "void" : "QObject"); } fprintf(out, " default: break;\n"); fprintf(out, " }\n"); -- cgit v1.2.3 From 629f5a46d531886cebe654a4ddb9269b62874e6a Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 11 May 2015 13:11:59 +0200 Subject: moc: Generate qt_static_metacall for creatable-only gadgets Prior to this, moc would not generate the function unless the gadget class had a property or a non-constructor invokable. Change-Id: Ic020ea5f8f59702f5e9e194a46e26850e53e5cfe Reviewed-by: Simon Hausmann Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/generator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 3b00e21208..5be58d3c4b 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -448,7 +448,8 @@ void Generator::generateCode() // Generate internal qt_static_metacall() function // const bool hasStaticMetaCall = !isQt && - (cdef->hasQObject || !cdef->methodList.isEmpty() || !cdef->propertyList.isEmpty()); + (cdef->hasQObject || !cdef->methodList.isEmpty() + || !cdef->propertyList.isEmpty() || !cdef->constructorList.isEmpty()); if (hasStaticMetaCall) generateStaticMetacall(); -- cgit v1.2.3 From f1fdac97abe2d9fedcf83469505f5704b3e2a26c Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 15 May 2015 14:35:43 +0200 Subject: qdoc: Improve logic for automatic example tag generation QDoc generates tags for examples based on the example title and the name of the module. This change makes the following improvements: - Edit regular expression to match strings like 'OpenGL' and 'Qt3D' as a single tag. - Strip off enclosing parentheses. - Filter out common words ('and', 'the') - When cleaning/modifying generated tags, keep them in a QSet to eliminate duplicates. Change-Id: I288104df12bf23a224068d40bce1f980148a412a Reviewed-by: Martin Smith --- src/tools/qdoc/htmlgenerator.cpp | 50 ++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'src/tools') diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 710ce08abb..8d84019ab5 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -4543,33 +4543,49 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString writer.writeCDATA(QString("No description available")); writer.writeEndElement(); // description - // Add words from module name as tags (QtQuickControls -> qt,quick,controls) - QRegExp re("([A-Z]+[a-z0-9]*)"); + // Add words from module name as tags + // QtQuickControls -> qt,quick,controls + // QtOpenGL -> qt,opengl + QRegExp re("([A-Z]+[a-z0-9]*(3D|GL)?)"); int pos = 0; while ((pos = re.indexIn(project, pos)) != -1) { tags << re.cap(1).toLower(); pos += re.matchedLength(); } tags += QSet::fromList(en->title().toLower().split(QLatin1Char(' '))); + + // Clean up tags, exclude invalid and common words + QSet::iterator tag_it = tags.begin(); + QSet modified; + while (tag_it != tags.end()) { + QString s = *tag_it; + if (s.at(0) == '(') + s.remove(0, 1).chop(1); + if (s.endsWith(QLatin1Char(':'))) + s.chop(1); + + if (s.length() < 2 + || s.at(0).isDigit() + || s.at(0) == '-' + || s == QStringLiteral("qt") + || s == QStringLiteral("the") + || s == QStringLiteral("and") + || s.startsWith(QStringLiteral("example")) + || s.startsWith(QStringLiteral("chapter"))) + tag_it = tags.erase(tag_it); + else if (s != *tag_it) { + modified << s; + tag_it = tags.erase(tag_it); + } + else + ++tag_it; + } + tags += modified; + if (!tags.isEmpty()) { writer.writeStartElement("tags"); bool wrote_one = false; - // Exclude invalid and common words foreach (QString tag, tags) { - if (tag.length() < 2) - continue; - if (tag.at(0).isDigit()) - continue; - if (tag.at(0) == '-') - continue; - if (tag == QLatin1String("qt")) - continue; - if (tag.startsWith("example")) - continue; - if (tag.startsWith("chapter")) - continue; - if (tag.endsWith(QLatin1Char(':'))) - tag.chop(1); if (wrote_one) writer.writeCharacters(","); writer.writeCharacters(tag); -- cgit v1.2.3 From 71c85c554a49ed3a17167e436630ddaff2b9fcb1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 29 May 2015 12:39:24 +0200 Subject: moc: Fix crash parsing invalid macro invocation When invoking a macro with less argument than it expect, we would crash trying to access the vector of arguments from the invocation as we are trying to substitute an argument. (Note that we do not show an error in case of argument mismatch because ithat might happen parsing valid code as moc's c++ parser is not 100% accurate (that was QTBUG-29331)) Task-number: QTBUG-46210 Change-Id: I3f08d7f5049e593a5bdc02a594ea63cadf66e7a4 Reviewed-by: Gabriel de Dietrich --- src/tools/moc/preprocessor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/tools') diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 51873033c7..f253c49995 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -661,8 +661,10 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym expansion += s; } } else if (mode == Hash) { - if (index < 0) + if (index < 0 || index >= arguments.size()) { that->error("'#' is not followed by a macro parameter"); + continue; + } const Symbols &arg = arguments.at(index); QByteArray stringified; @@ -681,7 +683,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym expansion.pop_back(); Symbol next = s; - if (index >= 0) { + if (index >= 0 && index < arguments.size()) { const Symbols &arg = arguments.at(index); if (arg.size() == 0) { mode = Normal; @@ -703,7 +705,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym expansion += next; } - if (index >= 0) { + if (index >= 0 && index < arguments.size()) { const Symbols &arg = arguments.at(index); for (int i = 1; i < arg.size(); ++i) expansion += arg.at(i); -- cgit v1.2.3 From f44a59f390be9b67365db8796aa6a54fe9241028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sun, 10 May 2015 12:26:47 +0100 Subject: Don't assign iterator to const_iterator It should also be possible to use QT_STRICT_ITERATORS in Qt's own code base Change-Id: I0914db480d4d2b06e71e3a2588163efdd3ff6d27 Reviewed-by: Marc Mutz Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/qdoc/htmlgenerator.cpp | 4 ++-- src/tools/qdoc/node.cpp | 12 ++++++------ src/tools/qdoc/puredocparser.cpp | 4 ++-- src/tools/qdoc/qdocdatabase.cpp | 4 ++-- src/tools/qdoc/tree.cpp | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/tools') diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 8d84019ab5..b340883c12 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -2199,7 +2199,7 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker) out() << "
\n"; QStringList::ConstIterator i; - for (i = requisiteorder.begin(); i != requisiteorder.constEnd(); ++i) { + for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) { if (requisites.contains(*i)) { out() << "" @@ -2319,7 +2319,7 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) out() << "
\n"; QStringList::ConstIterator i; - for (i = requisiteorder.begin(); i != requisiteorder.constEnd(); ++i) { + for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) { if (requisites.contains(*i)) { out() << "" diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index 230ce50df8..37bc0c5fef 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -2763,8 +2763,8 @@ bool CollectionNode::hasNamespaces() const bool CollectionNode::hasClasses() const { if (!members_.isEmpty()) { - NodeList::const_iterator i = members_.begin(); - while (i != members_.end()) { + NodeList::const_iterator i = members_.cbegin(); + while (i != members_.cend()) { if ((*i)->isClass()) return true; ++i; @@ -2780,8 +2780,8 @@ bool CollectionNode::hasClasses() const void CollectionNode::getMemberNamespaces(NodeMap& out) { out.clear(); - NodeList::const_iterator i = members_.begin(); - while (i != members_.end()) { + NodeList::const_iterator i = members_.cbegin(); + while (i != members_.cend()) { if ((*i)->isNamespace()) out.insert((*i)->name(),(*i)); ++i; @@ -2795,8 +2795,8 @@ void CollectionNode::getMemberNamespaces(NodeMap& out) void CollectionNode::getMemberClasses(NodeMap& out) { out.clear(); - NodeList::const_iterator i = members_.begin(); - while (i != members_.end()) { + NodeList::const_iterator i = members_.cbegin(); + while (i != members_.cend()) { if ((*i)->isClass()) out.insert((*i)->name(),(*i)); ++i; diff --git a/src/tools/qdoc/puredocparser.cpp b/src/tools/qdoc/puredocparser.cpp index 7029431460..e47460efb2 100644 --- a/src/tools/qdoc/puredocparser.cpp +++ b/src/tools/qdoc/puredocparser.cpp @@ -188,8 +188,8 @@ bool PureDocParser::processQdocComments() topics.insert(i+1,"and"); doc.location().warning(tr("Multiple topic commands found in comment: %1").arg(topics)); } - ArgList::ConstIterator a = args.begin(); - while (a != args.end()) { + ArgList::ConstIterator a = args.cbegin(); + while (a != args.cend()) { Doc nodeDoc = doc; Node* node = processTopicCommand(nodeDoc,topic,*a); if (node != 0) { diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp index f1afb92eff..bf84fa8335 100644 --- a/src/tools/qdoc/qdocdatabase.cpp +++ b/src/tools/qdoc/qdocdatabase.cpp @@ -1549,8 +1549,8 @@ void QDocDatabase::mergeCollections(Node::Genus genus, CNMap& cnm, const Node* r foreach (Tree* t, searchOrder()) { CNMap* m = t->getCollectionMap(genus); if (m && !m->isEmpty()) { - CNMap::const_iterator i = m->begin(); - while (i != m->end()) { + CNMap::const_iterator i = m->cbegin(); + while (i != m->cend()) { if (!i.value()->isInternal()) cnmm.insert(i.key(), i.value()); ++i; diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp index 420396e51c..1b0aba1a0c 100644 --- a/src/tools/qdoc/tree.cpp +++ b/src/tools/qdoc/tree.cpp @@ -1222,8 +1222,8 @@ CollectionNode* Tree::getCollection(const QString& name, Node::Genus genus) { CNMap* m = getCollectionMap(genus); if (m) { - CNMap::const_iterator i = m->find(name); - if (i != m->end()) + CNMap::const_iterator i = m->constFind(name); + if (i != m->cend()) return i.value(); } return 0; @@ -1249,8 +1249,8 @@ CollectionNode* Tree::findCollection(const QString& name, Node::Genus genus) CNMap* m = getCollectionMap(genus); if (!m) // error return 0; - CNMap::const_iterator i = m->find(name); - if (i != m->end()) + CNMap::const_iterator i = m->constFind(name); + if (i != m->cend()) return i.value(); Node::Type t = Node::NoType; switch (genus) { -- cgit v1.2.3