aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2011-09-08 14:01:18 +0200
committerEike Ziller <eike.ziller@nokia.com>2011-09-12 08:39:49 +0200
commitc5694cc5e1959e5c6b9bfbc17c165313dd41118a (patch)
tree85cc49f0338e2da1283efb28452cac34744e6756
parent55606d5db69a0c33db8ed4b6a03e66580625d945 (diff)
C++: Fix duplicate items in C++ completion for Qt methods
In the old code completion engine items were created on the stack and passed around by value. With the refactoring of the code assist API they became heap objects manipulated through pointers. This patch fixes one reminiscence not caught during the refactoring in which the same actual pointer was being used more than once to be appended on the list. Change-Id: I2009fb0b6aa18df57aa5ca9bde0591536ca2cd74 Reviewed-on: http://codereview.qt-project.org/4444 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com> (cherry picked from commit a1fa169219423641e65f81e3fbc27f0f9fb84dd5)
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp54
1 files changed, 26 insertions, 28 deletions
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index d2c458f56f..dddbca6e2f 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -1614,40 +1614,38 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
continue;
else if (! wantSignals && ! fun->isSlot())
continue;
- BasicProposalItem *item = toCompletionItem(fun);
- if (item) {
- unsigned count = fun->argumentCount();
- while (true) {
- BasicProposalItem *ci = item;
-
- QString signature;
- signature += Overview().prettyName(fun->name());
- signature += QLatin1Char('(');
- for (unsigned i = 0; i < count; ++i) {
- Symbol *arg = fun->argumentAt(i);
- if (i != 0)
- signature += QLatin1Char(',');
- signature += o.prettyType(arg->type());
- }
- signature += QLatin1Char(')');
-
- const QByteArray normalized =
- QMetaObject::normalizedSignature(signature.toLatin1());
- signature = QString::fromLatin1(normalized, normalized.size());
+ unsigned count = fun->argumentCount();
+ while (true) {
+ QString signature;
+ signature += Overview().prettyName(fun->name());
+ signature += QLatin1Char('(');
+ for (unsigned i = 0; i < count; ++i) {
+ Symbol *arg = fun->argumentAt(i);
+ if (i != 0)
+ signature += QLatin1Char(',');
+ signature += o.prettyType(arg->type());
+ }
+ signature += QLatin1Char(')');
- if (! signatures.contains(signature)) {
- signatures.insert(signature);
+ const QByteArray normalized =
+ QMetaObject::normalizedSignature(signature.toLatin1());
- ci->setText(signature); // fix the completion item.
- m_completions.append(ci);
- }
+ signature = QString::fromLatin1(normalized, normalized.size());
- if (count && fun->argumentAt(count - 1)->asArgument()->hasInitializer())
- --count;
- else
+ if (! signatures.contains(signature)) {
+ BasicProposalItem *ci = toCompletionItem(fun);
+ if (!ci)
break;
+ signatures.insert(signature);
+ ci->setText(signature); // fix the completion item.
+ m_completions.append(ci);
}
+
+ if (count && fun->argumentAt(count - 1)->asArgument()->hasInitializer())
+ --count;
+ else
+ break;
}
}
}