forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Leandro T. C. Melo
parent
d6e46f7a84
commit
a1fa169219
@@ -1616,12 +1616,9 @@ 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();
|
unsigned count = fun->argumentCount();
|
||||||
while (true) {
|
while (true) {
|
||||||
BasicProposalItem *ci = item;
|
|
||||||
|
|
||||||
QString signature;
|
QString signature;
|
||||||
signature += Overview().prettyName(fun->name());
|
signature += Overview().prettyName(fun->name());
|
||||||
signature += QLatin1Char('(');
|
signature += QLatin1Char('(');
|
||||||
@@ -1639,8 +1636,10 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
|
|||||||
signature = QString::fromLatin1(normalized, normalized.size());
|
signature = QString::fromLatin1(normalized, normalized.size());
|
||||||
|
|
||||||
if (! signatures.contains(signature)) {
|
if (! signatures.contains(signature)) {
|
||||||
|
BasicProposalItem *ci = toCompletionItem(fun);
|
||||||
|
if (!ci)
|
||||||
|
break;
|
||||||
signatures.insert(signature);
|
signatures.insert(signature);
|
||||||
|
|
||||||
ci->setText(signature); // fix the completion item.
|
ci->setText(signature); // fix the completion item.
|
||||||
m_completions.append(ci);
|
m_completions.append(ci);
|
||||||
}
|
}
|
||||||
@@ -1653,7 +1652,6 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ! m_completions.isEmpty();
|
return ! m_completions.isEmpty();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user