diff --git a/src/plugins/cppeditor/cppcheckundefinedsymbols.cpp b/src/plugins/cppeditor/cppcheckundefinedsymbols.cpp index 7e9bffa9c1147e5d3c8785353897ca8b870042dd..0e16c51bb8f61070f6728fed1816dd922ba6096f 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<Use> &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 14c9335a76dfc4f7ba30bd6a13367613a6d168c7..4dbc0b52f3c7b6ede4e89879234c84af563c423a 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<CppEditor::Internal::SemanticInfo::Use> { public: virtual ~CheckUndefinedSymbols(); typedef CppEditor::Internal::SemanticInfo::Use Use; - void runFunctor(QFutureInterface<Use> &future); + virtual void run(); + void runFunctor(); typedef QFuture<Use> Future; static Future go(Document::Ptr doc, const LookupContext &context); @@ -100,7 +103,6 @@ private: QList<ScopedSymbol *> _scopes; QList<TemplateDeclarationAST *> _templateDeclarationStack; QVector<Use> _typeUsages; - QFutureInterface<Use> *_future; }; } // end of namespace CPlusPlus