Skip to content
Snippets Groups Projects
Commit 7d7288cf authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Refactored CheckUndefinedSymbols to use RunFunctionTaskBase.

This will eventually fix a few leaks we introduced in the semantic highlighter.
parent 54584044
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment