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

Revert "Don't wait for the dependencyTable computation in the GUI thread."

OK, it seems that this change is not necessary.

This reverts commit 40bae63c.
parent 40bae63c
No related branches found
No related tags found
No related merge requests found
...@@ -157,8 +157,6 @@ CppFindReferences::CppFindReferences(CppTools::CppModelManagerInterface *modelMa ...@@ -157,8 +157,6 @@ CppFindReferences::CppFindReferences(CppTools::CppModelManagerInterface *modelMa
connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int))); connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int)));
connect(&m_watcher, SIGNAL(finished()), this, SLOT(searchFinished())); connect(&m_watcher, SIGNAL(finished()), this, SLOT(searchFinished()));
connect(&m_watchDependencyTable, SIGNAL(finished()), this, SLOT(dependencyTableUpdated()));
m_updateDependencyTableTimer = new QTimer(this); m_updateDependencyTableTimer = new QTimer(this);
m_updateDependencyTableTimer->setSingleShot(true); m_updateDependencyTableTimer->setSingleShot(true);
m_updateDependencyTableTimer->setInterval(2000); m_updateDependencyTableTimer->setInterval(2000);
...@@ -190,10 +188,11 @@ static void find_helper(QFutureInterface<Usage> &future, ...@@ -190,10 +188,11 @@ static void find_helper(QFutureInterface<Usage> &future,
const CppTools::CppModelManagerInterface::WorkingCopy workingCopy, const CppTools::CppModelManagerInterface::WorkingCopy workingCopy,
Snapshot snapshot, Snapshot snapshot,
Document::Ptr symbolDocument, Document::Ptr symbolDocument,
QFuture<DependencyTable> dependencyTableFuture, DependencyTable dependencyTable,
Symbol *symbol) Symbol *symbol)
{ {
const DependencyTable dependencyTable = dependencyTableFuture; QTime tm;
tm.start();
const Identifier *symbolId = symbol->identifier(); const Identifier *symbolId = symbol->identifier();
Q_ASSERT(symbolId != 0); Q_ASSERT(symbolId != 0);
...@@ -227,7 +226,7 @@ static void find_helper(QFutureInterface<Usage> &future, ...@@ -227,7 +226,7 @@ static void find_helper(QFutureInterface<Usage> &future,
future.setProgressValue(files.size()); future.setProgressValue(files.size());
} }
static CPlusPlus::DependencyTable dependencyTable_helper(DependencyTable previous, CPlusPlus::Snapshot snapshot) static CPlusPlus::DependencyTable dependencyTable(DependencyTable previous, CPlusPlus::Snapshot snapshot)
{ {
if (previous.isValidFor(snapshot)) if (previous.isValidFor(snapshot))
return previous; return previous;
...@@ -239,14 +238,8 @@ static CPlusPlus::DependencyTable dependencyTable_helper(DependencyTable previou ...@@ -239,14 +238,8 @@ static CPlusPlus::DependencyTable dependencyTable_helper(DependencyTable previou
void CppFindReferences::updateDependencyTable() void CppFindReferences::updateDependencyTable()
{ {
m_dependencyTableFuture.cancel(); m_depsFuture.cancel();
m_dependencyTableFuture = QtConcurrent::run(&dependencyTable_helper, m_deps, _modelManager->snapshot()); m_depsFuture = QtConcurrent::run(&dependencyTable, m_deps, _modelManager->snapshot());
m_watchDependencyTable.setFuture(m_dependencyTableFuture);
}
void CppFindReferences::dependencyTableUpdated()
{
m_deps = m_dependencyTableFuture;
} }
void CppFindReferences::findUsages(Document::Ptr symbolDocument, Symbol *symbol) void CppFindReferences::findUsages(Document::Ptr symbolDocument, Symbol *symbol)
...@@ -290,10 +283,11 @@ void CppFindReferences::findAll_helper(Document::Ptr symbolDocument, Symbol *sym ...@@ -290,10 +283,11 @@ void CppFindReferences::findAll_helper(Document::Ptr symbolDocument, Symbol *sym
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager(); Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
updateDependencyTable(); // ensure the dependency table is updated updateDependencyTable(); // ensure the dependency table is updated
m_deps = m_depsFuture;
QFuture<Usage> result; QFuture<Usage> result;
result = QtConcurrent::run(&find_helper, workingCopy, snapshot, symbolDocument, m_dependencyTableFuture, symbol); result = QtConcurrent::run(&find_helper, workingCopy, snapshot, symbolDocument, m_deps, symbol);
m_watcher.setFuture(result); m_watcher.setFuture(result);
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"), Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
...@@ -411,10 +405,9 @@ public: ...@@ -411,10 +405,9 @@ public:
static void findMacroUses_helper(QFutureInterface<Usage> &future, static void findMacroUses_helper(QFutureInterface<Usage> &future,
const CppTools::CppModelManagerInterface::WorkingCopy workingCopy, const CppTools::CppModelManagerInterface::WorkingCopy workingCopy,
const Snapshot snapshot, const Snapshot snapshot,
QFuture<DependencyTable> dependencyTableFuture, DependencyTable dependencyTable,
const Macro macro) const Macro macro)
{ {
const DependencyTable dependencyTable = dependencyTableFuture;
const QString& sourceFile = macro.fileName(); const QString& sourceFile = macro.fileName();
QStringList files(sourceFile); QStringList files(sourceFile);
files += dependencyTable.filesDependingOn(sourceFile); files += dependencyTable.filesDependingOn(sourceFile);
...@@ -450,9 +443,10 @@ void CppFindReferences::findMacroUses(const Macro &macro) ...@@ -450,9 +443,10 @@ void CppFindReferences::findMacroUses(const Macro &macro)
} }
updateDependencyTable(); // ensure the dependency table is updated updateDependencyTable(); // ensure the dependency table is updated
m_deps = m_depsFuture;
QFuture<Usage> result; QFuture<Usage> result;
result = QtConcurrent::run(&findMacroUses_helper, workingCopy, snapshot, m_dependencyTableFuture, macro); result = QtConcurrent::run(&findMacroUses_helper, workingCopy, snapshot, m_deps, macro);
m_watcher.setFuture(result); m_watcher.setFuture(result);
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager(); Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
......
...@@ -78,7 +78,6 @@ private Q_SLOTS: ...@@ -78,7 +78,6 @@ private Q_SLOTS:
void openEditor(const Find::SearchResultItem &item); void openEditor(const Find::SearchResultItem &item);
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items); void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
void updateDependencyTable(); void updateDependencyTable();
void dependencyTableUpdated();
private: private:
void findAll_helper(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol); void findAll_helper(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol);
...@@ -87,9 +86,8 @@ private: ...@@ -87,9 +86,8 @@ private:
QPointer<CppModelManagerInterface> _modelManager; QPointer<CppModelManagerInterface> _modelManager;
Find::SearchResultWindow *_resultWindow; Find::SearchResultWindow *_resultWindow;
QFutureWatcher<CPlusPlus::Usage> m_watcher; QFutureWatcher<CPlusPlus::Usage> m_watcher;
QFutureWatcher<CPlusPlus::DependencyTable> m_watchDependencyTable;
CPlusPlus::DependencyTable m_deps; CPlusPlus::DependencyTable m_deps;
QFuture<CPlusPlus::DependencyTable> m_dependencyTableFuture; QFuture<CPlusPlus::DependencyTable> m_depsFuture;
QTimer *m_updateDependencyTableTimer; QTimer *m_updateDependencyTableTimer;
}; };
......
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