diff --git a/src/plugins/cppeditor/cppcheckundefinedsymbols.cpp b/src/plugins/cppeditor/cppcheckundefinedsymbols.cpp index 7e9bffa9c11..0e16c51bb8f 100644 --- a/src/plugins/cppeditor/cppcheckundefinedsymbols.cpp +++ b/src/plugins/cppeditor/cppcheckundefinedsymbols.cpp @@ -258,11 +258,11 @@ protected: CheckUndefinedSymbols::Future CheckUndefinedSymbols::go(Document::Ptr doc, const LookupContext &context) { Q_ASSERT(doc); - return QtConcurrent::run(&CheckUndefinedSymbols::runFunctor, new CheckUndefinedSymbols(doc, context)); + return (new CheckUndefinedSymbols(doc, context))->start(); } CheckUndefinedSymbols::CheckUndefinedSymbols(Document::Ptr doc, const LookupContext &context) - : ASTVisitor(doc->translationUnit()), _doc(doc), _context(context), _future(0) + : ASTVisitor(doc->translationUnit()), _doc(doc), _context(context) { _fileName = doc->fileName(); CollectTypes collectTypes(doc, context.snapshot()); @@ -273,9 +273,16 @@ CheckUndefinedSymbols::CheckUndefinedSymbols(Document::Ptr doc, const LookupCont CheckUndefinedSymbols::~CheckUndefinedSymbols() { } -void CheckUndefinedSymbols::runFunctor(QFutureInterface &future) +void CheckUndefinedSymbols::run() +{ + if (! isCanceled()) + runFunctor(); + + reportFinished(); +} + +void CheckUndefinedSymbols::runFunctor() { - _future = &future; _diagnosticMessages.clear(); if (_doc->translationUnit()) { @@ -306,7 +313,7 @@ bool CheckUndefinedSymbols::warning(AST *ast, const QString &text) bool CheckUndefinedSymbols::preVisit(AST *) { - if (_future->isCanceled()) + if (isCanceled()) return false; return true; @@ -559,6 +566,6 @@ void CheckUndefinedSymbols::flush() if (_typeUsages.isEmpty()) return; - _future->reportResults(_typeUsages); + reportResults(_typeUsages); _typeUsages.clear(); } diff --git a/src/plugins/cppeditor/cppcheckundefinedsymbols.h b/src/plugins/cppeditor/cppcheckundefinedsymbols.h index 14c9335a76d..4dbc0b52f3c 100644 --- a/src/plugins/cppeditor/cppcheckundefinedsymbols.h +++ b/src/plugins/cppeditor/cppcheckundefinedsymbols.h @@ -41,14 +41,17 @@ namespace CPlusPlus { -class CheckUndefinedSymbols: protected ASTVisitor +class CheckUndefinedSymbols: + protected ASTVisitor, + public QtConcurrent::RunFunctionTaskBase { public: virtual ~CheckUndefinedSymbols(); typedef CppEditor::Internal::SemanticInfo::Use Use; - void runFunctor(QFutureInterface &future); + virtual void run(); + void runFunctor(); typedef QFuture Future; static Future go(Document::Ptr doc, const LookupContext &context); @@ -100,7 +103,6 @@ private: QList _scopes; QList _templateDeclarationStack; QVector _typeUsages; - QFutureInterface *_future; }; } // end of namespace CPlusPlus