From c3737573ced4dc2217f31aac627fa8070e7512c8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Apr 2015 08:25:28 +0200 Subject: uic: Delay the setting of QPushButton::default. For the property to take effect, the button must have its parent set. This might not be the case when a container like for example QTabWidget is involved. Move the setting of the property to the bottom of setupUi. Task-number: QTBUG-44406 Change-Id: Ic2013865a020986475fa28f2e3805c63d4de8ed0 Reviewed-by: Marc Mutz --- src/tools/uic/cpp/cppwriteinitialization.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 78f243a6d3..b02e2dc0ed 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1176,6 +1176,7 @@ void WriteInitialization::writeProperties(const QString &varName, continue; QString propertyName = p->attributeName(); QString propertyValue; + bool delayProperty = false; // special case for the property `geometry': Do not use position if (isTopLevel && propertyName == QLatin1String("geometry") && p->elementRect()) { @@ -1204,6 +1205,10 @@ void WriteInitialization::writeProperties(const QString &varName, && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { // already done ;) continue; + } else if (propertyName == QLatin1String("default") + && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QPushButton"))) { + // QTBUG-44406: Setting of QPushButton::default needs to be delayed until the parent is set + delayProperty = true; } else if (propertyName == QLatin1String("database") && p->elementStringList()) { // Sql support @@ -1479,7 +1484,7 @@ void WriteInitialization::writeProperties(const QString &varName, else if (propertyName == QLatin1String("accessibleName") || propertyName == QLatin1String("accessibleDescription")) defineC = accessibilityDefineC; - QTextStream &o = autoTrOutput(p); + QTextStream &o = delayProperty ? m_delayedOut : autoTrOutput(p); if (defineC) openIfndef(o, QLatin1String(defineC)); -- cgit v1.2.3 From 21c90bcc989cc18ba926cf4dbfbc9d2fce78dd63 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 17 Apr 2015 14:57:21 +0200 Subject: qdoc: Sanitize anchors in URLs for functions When QDoc constructs the full path to a documentation node, it must construct a clean anchor reference. Intra-page links use a different code path, so the links e.g. from Member Functions list to their detailed descriptions always work, but using the link command to link to functions with certain characters (such as 'operator==') failed because the node name was used as-is and not sanitized ('operator-eq-eq'). This change moves HtmlGenerator::cleanRef() static function to its parent class, Generator, and takes it into use in Generator::fullDocumentLocation(). Change-Id: Ic939ffa3ae0f4495ef2a30eff0d4a1de65ea3e8f Task-number: QTBUG-45629 Reviewed-by: Martin Smith --- src/tools/qdoc/generator.cpp | 57 ++++++++++++++++++++++++++++++++++++++-- src/tools/qdoc/generator.h | 1 + src/tools/qdoc/htmlgenerator.cpp | 57 ++-------------------------------------- src/tools/qdoc/htmlgenerator.h | 1 - 4 files changed, 58 insertions(+), 58 deletions(-) (limited to 'src/tools') diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp index 2ff4df9bd7..d22ec507f6 100644 --- a/src/tools/qdoc/generator.cpp +++ b/src/tools/qdoc/generator.cpp @@ -419,6 +419,59 @@ QString Generator::fileName(const Node* node) const return name; } +QString Generator::cleanRef(const QString& ref) +{ + QString clean; + + if (ref.isEmpty()) + return clean; + + clean.reserve(ref.size() + 20); + const QChar c = ref[0]; + const uint u = c.unicode(); + + if ((u >= 'a' && u <= 'z') || + (u >= 'A' && u <= 'Z') || + (u >= '0' && u <= '9')) { + clean += c; + } else if (u == '~') { + clean += "dtor."; + } else if (u == '_') { + clean += "underscore."; + } else { + clean += QLatin1Char('A'); + } + + for (int i = 1; i < (int) ref.length(); i++) { + const QChar c = ref[i]; + const uint u = c.unicode(); + if ((u >= 'a' && u <= 'z') || + (u >= 'A' && u <= 'Z') || + (u >= '0' && u <= '9') || u == '-' || + u == '_' || u == ':' || u == '.') { + clean += c; + } else if (c.isSpace()) { + clean += QLatin1Char('-'); + } else if (u == '!') { + clean += "-not"; + } else if (u == '&') { + clean += "-and"; + } else if (u == '<') { + clean += "-lt"; + } else if (u == '=') { + clean += "-eq"; + } else if (u == '>') { + clean += "-gt"; + } else if (u == '#') { + clean += QLatin1Char('#'); + } else { + clean += QLatin1Char('-'); + clean += QString::number((int)u, 16); + } + } + return clean; +} + QMap& Generator::formattingLeftMap() { return fmtLeftMaps[format()]; @@ -521,10 +574,10 @@ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir) return fullDocumentLocation(functionNode->associatedProperty()); else if (functionNode->overloadNumber() > 1) - anchorRef = QLatin1Char('#') + functionNode->name() + anchorRef = QLatin1Char('#') + cleanRef(functionNode->name()) + QLatin1Char('-') + QString::number(functionNode->overloadNumber()); else - anchorRef = QLatin1Char('#') + functionNode->name(); + anchorRef = QLatin1Char('#') + cleanRef(functionNode->name()); break; } /* diff --git a/src/tools/qdoc/generator.h b/src/tools/qdoc/generator.h index 6d0de8df44..9a1672dac4 100644 --- a/src/tools/qdoc/generator.h +++ b/src/tools/qdoc/generator.h @@ -103,6 +103,7 @@ public: static bool useOutputSubdirs() { return useOutputSubdirs_; } static void setQmlTypeContext(QmlTypeNode* t) { qmlTypeContext_ = t; } static QmlTypeNode* qmlTypeContext() { return qmlTypeContext_; } + static QString cleanRef(const QString& ref); protected: virtual void beginSubPage(const InnerNode* node, const QString& fileName); diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index f0a23ac65e..710ce08abb 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -3355,7 +3355,7 @@ void HtmlGenerator::generateSectionInheritedList(const Section& section, const N out() << section.pluralMember; } out() << " inherited from " + << '#' << Generator::cleanRef(section.name.toLower()) << "\">" << protectEnc((*p).first->plainFullName(relative)) << "\n"; ++p; @@ -3610,62 +3610,9 @@ void HtmlGenerator::generateLink(const Atom* atom, CodeMarker* marker) } } -QString HtmlGenerator::cleanRef(const QString& ref) -{ - QString clean; - - if (ref.isEmpty()) - return clean; - - clean.reserve(ref.size() + 20); - const QChar c = ref[0]; - const uint u = c.unicode(); - - if ((u >= 'a' && u <= 'z') || - (u >= 'A' && u <= 'Z') || - (u >= '0' && u <= '9')) { - clean += c; - } else if (u == '~') { - clean += "dtor."; - } else if (u == '_') { - clean += "underscore."; - } else { - clean += QLatin1Char('A'); - } - - for (int i = 1; i < (int) ref.length(); i++) { - const QChar c = ref[i]; - const uint u = c.unicode(); - if ((u >= 'a' && u <= 'z') || - (u >= 'A' && u <= 'Z') || - (u >= '0' && u <= '9') || u == '-' || - u == '_' || u == ':' || u == '.') { - clean += c; - } else if (c.isSpace()) { - clean += QLatin1Char('-'); - } else if (u == '!') { - clean += "-not"; - } else if (u == '&') { - clean += "-and"; - } else if (u == '<') { - clean += "-lt"; - } else if (u == '=') { - clean += "-eq"; - } else if (u == '>') { - clean += "-gt"; - } else if (u == '#') { - clean += QLatin1Char('#'); - } else { - clean += QLatin1Char('-'); - clean += QString::number((int)u, 16); - } - } - return clean; -} - QString HtmlGenerator::registerRef(const QString& ref) { - QString clean = HtmlGenerator::cleanRef(ref); + QString clean = Generator::cleanRef(ref); for (;;) { QString& prevRef = refMap[clean.toLower()]; diff --git a/src/tools/qdoc/htmlgenerator.h b/src/tools/qdoc/htmlgenerator.h index efd38ea104..4a2e158252 100644 --- a/src/tools/qdoc/htmlgenerator.h +++ b/src/tools/qdoc/htmlgenerator.h @@ -85,7 +85,6 @@ public: QString protectEnc(const QString &string); static QString protect(const QString &string, const QString &encoding = "ISO-8859-1"); - static QString cleanRef(const QString& ref); static QString sinceTitle(int i) { return sinceTitles[i]; } protected: -- cgit v1.2.3 From 3e7cf5981aa536c18aee814b9f5e221c5a8a4d1a Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 15 Apr 2015 14:14:30 +0200 Subject: qdoc: Resolve base classes for a class declared in a namespace For classes declared in a namespace, QDoc needs to take account the fact that its base classes typically are not qualified with the namespace name if those base classes are from the same namespace. There already was code for this, but it was disabled by a macro. This change re-enables it, and adds an additional check to restart the search in valid namespaces only. Change-Id: Ia07dcb783b59de5fc9ddcfd43000a63c6c74ebe1 Reviewed-by: Martin Smith --- src/tools/qdoc/tree.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/tools') diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp index d0d0bcbb5a..420396e51c 100644 --- a/src/tools/qdoc/tree.cpp +++ b/src/tools/qdoc/tree.cpp @@ -388,7 +388,6 @@ void Tree::resolveInheritanceHelper(int pass, ClassNode* cn) while (b != bases.end()) { if (!(*b).node_) { Node* n = qdb_->findClassNode((*b).path_); -#if 0 /* If the node for the base class was not found, the reason might be that the subclass is in a @@ -401,9 +400,11 @@ void Tree::resolveInheritanceHelper(int pass, ClassNode* cn) */ if (!n) { InnerNode* parent = cn->parent(); - n = findClassNode((*b).path_, parent); + if (parent) + // Exclude the root namespace + if (parent->isNamespace() && !parent->name().isEmpty()) + n = findClassNode((*b).path_, parent); } -#endif if (n) { ClassNode* bcn = static_cast(n); (*b).node_ = bcn; -- cgit v1.2.3 From 0635b1a69dd666f5eed4b096895bd80b1a9420ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20Ca=C5=82usi=C5=84ski?= Date: Fri, 24 Apr 2015 11:26:01 +0200 Subject: Moc: test if superclass list is not empty before accessing first() Accessing QList().first() with an empty superclassList caused assertion fail. Added check to fix it. Change-Id: I1aff35e0d267fc0e670beadba1bd196b175a4da8 Co-authored-with: Olivier Goffart Task-number: QTBUG-45790 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/moc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index a9e33da01d..7300429fe0 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -140,7 +140,8 @@ bool Moc::parseClassHead(ClassDef *def) } } while (test(COMMA)); - if (knownGadgets.contains(def->superclassList.first().first)) { + if (!def->superclassList.isEmpty() + && knownGadgets.contains(def->superclassList.first().first)) { // Q_GADGET subclasses are treated as Q_GADGETs knownGadgets.insert(def->classname, def->qualified); knownGadgets.insert(def->qualified, def->qualified); -- cgit v1.2.3