Commit a1fa1692 authored by Leandro Melo's avatar Leandro Melo Committed by Leandro T. C. Melo

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/4444Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@nokia.com>
parent d6e46f7a
...@@ -1616,40 +1616,38 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku ...@@ -1616,40 +1616,38 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
continue; continue;
else if (! wantSignals && ! fun->isSlot()) else if (! wantSignals && ! fun->isSlot())
continue; 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)) { const QByteArray normalized =
signatures.insert(signature); QMetaObject::normalizedSignature(signature.toLatin1());
ci->setText(signature); // fix the completion item. signature = QString::fromLatin1(normalized, normalized.size());
m_completions.append(ci);
}
if (count && fun->argumentAt(count - 1)->asArgument()->hasInitializer()) if (! signatures.contains(signature)) {
--count; BasicProposalItem *ci = toCompletionItem(fun);
else if (!ci)
break; 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;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment