summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-03-05 14:59:37 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-03-05 15:00:17 (GMT)
commitddaa4643c1ee96c9dfc16b1c247481a240e2e16b (patch)
tree9036fd23c998af603f081fdebc81d42045ba4c22 /tools/linguist
parent856f76e44a00a710b1c34eddee5a893a3c0ada6a (diff)
downloadQt-ddaa4643c1ee96c9dfc16b1c247481a240e2e16b.zip
Qt-ddaa4643c1ee96c9dfc16b1c247481a240e2e16b.tar.gz
Qt-ddaa4643c1ee96c9dfc16b1c247481a240e2e16b.tar.bz2
fix "using namespace" recursion crash
Task-number: QTBUG-8360
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/lupdate/cpp.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index 6bd9108..2d5620e 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -260,6 +260,8 @@ private:
bool qualifyOneCallbackOwn(const Namespace *ns, void *context) const;
bool qualifyOneCallbackUsing(const Namespace *ns, void *context) const;
bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
+ NamespaceList *resolved, QSet<HashStringList> *visitedUsings) const;
+ bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
NamespaceList *resolved) const;
bool fullyQualify(const NamespaceList &namespaces, int nsCnt,
const QList<HashString> &segments, bool isDeclaration,
@@ -1036,15 +1038,16 @@ QStringList CppParser::stringListifySegments(const QList<HashString> &segments)
}
struct QualifyOneData {
- QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd)
- : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd)
+ QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd,
+ QSet<HashStringList> *visited)
+ : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd), visitedUsings(visited)
{}
const NamespaceList &namespaces;
int nsCount;
const HashString &segment;
NamespaceList *resolved;
- QSet<HashStringList> visitedUsings;
+ QSet<HashStringList> *visitedUsings;
};
bool CppParser::qualifyOneCallbackOwn(const Namespace *ns, void *context) const
@@ -1078,18 +1081,19 @@ bool CppParser::qualifyOneCallbackUsing(const Namespace *ns, void *context) cons
{
QualifyOneData *data = (QualifyOneData *)context;
foreach (const HashStringList &use, ns->usings)
- if (!data->visitedUsings.contains(use)) {
- data->visitedUsings.insert(use);
- if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved))
+ if (!data->visitedUsings->contains(use)) {
+ data->visitedUsings->insert(use);
+ if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved,
+ data->visitedUsings))
return true;
}
return false;
}
bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
- NamespaceList *resolved) const
+ NamespaceList *resolved, QSet<HashStringList> *visitedUsings) const
{
- QualifyOneData data(namespaces, nsCnt, segment, resolved);
+ QualifyOneData data(namespaces, nsCnt, segment, resolved, visitedUsings);
if (visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackOwn, &data))
return true;
@@ -1097,6 +1101,14 @@ bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const Has
return visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackUsing, &data);
}
+bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
+ NamespaceList *resolved) const
+{
+ QSet<HashStringList> visitedUsings;
+
+ return qualifyOne(namespaces, nsCnt, segment, resolved, &visitedUsings);
+}
+
bool CppParser::fullyQualify(const NamespaceList &namespaces, int nsCnt,
const QList<HashString> &segments, bool isDeclaration,
NamespaceList *resolved, QStringList *unresolved) const