forked from qt-creator/qt-creator
ClangTools: Avoid freezing UI for many items
...if new items are added to the model or if filter is used. When items were added, we have called ClangToolsDiagnosticModel::diagnostics() two times: * from DiagnosticFilterModel::filterAcceptsRow() * from ClangTidyClazyTool::handleStateUpdate() However, this does not scale since diagnostics() creates a temporary. Fix this by accessing the diagnostics or the count directly from the tree. Change-Id: I4c6a32e0076c1b4228ed1b1ff9222c9918f92c5c Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -80,6 +80,11 @@ QList<Diagnostic> ClangToolsDiagnosticModel::diagnostics() const
|
||||
return diags;
|
||||
}
|
||||
|
||||
int ClangToolsDiagnosticModel::diagnosticsCount() const
|
||||
{
|
||||
return rootItem()->childCount();
|
||||
}
|
||||
|
||||
static QString createDiagnosticToolTipString(const Diagnostic &diagnostic)
|
||||
{
|
||||
typedef QPair<QString, QString> StringPair;
|
||||
@@ -431,8 +436,9 @@ bool DiagnosticFilterModel::filterAcceptsRow(int sourceRow,
|
||||
return true;
|
||||
|
||||
// Is the diagnostic suppressed?
|
||||
const Diagnostic diag = static_cast<ClangToolsDiagnosticModel *>(sourceModel())
|
||||
->diagnostics().at(sourceRow);
|
||||
auto model = static_cast<ClangToolsDiagnosticModel *>(sourceModel());
|
||||
auto item = static_cast<DiagnosticItem *>(model->rootItem()->childAt(sourceRow));
|
||||
const Diagnostic &diag = item->diagnostic();
|
||||
foreach (const SuppressedDiagnostic &d, m_suppressedDiagnostics) {
|
||||
if (d.description != diag.description)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user