summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppfindreferences.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2010-03-09 17:35:24 +0100
committerErik Verbruggen <erik.verbruggen@nokia.com>2010-03-09 17:38:02 +0100
commit417a1c9f284fd4a8c66177eb9f2e65b36b910c15 (patch)
treed12f5686e4ef38ea4512296f2e91df8e03283160 /src/plugins/cpptools/cppfindreferences.cpp
parente35a1e612a8817b3393967d7aea9e86564c210cc (diff)
downloadqt-creator-417a1c9f284fd4a8c66177eb9f2e65b36b910c15.tar.gz
Fixed QTCREATORBUG-745.
Fixed crash in FindUsages on a dirty file in a large project, which is saved while the FindUsages is still running.
Diffstat (limited to 'src/plugins/cpptools/cppfindreferences.cpp')
-rw-r--r--src/plugins/cpptools/cppfindreferences.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp
index 4f25edf2f7..e714fa28ab 100644
--- a/src/plugins/cpptools/cppfindreferences.cpp
+++ b/src/plugins/cpptools/cppfindreferences.cpp
@@ -85,13 +85,15 @@ class ProcessFile: public std::unary_function<QString, QList<Usage> >
{
const CppTools::CppModelManagerInterface::WorkingCopy workingCopy;
const Snapshot snapshot;
+ Document::Ptr symbolDocument;
Symbol *symbol;
public:
ProcessFile(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy,
const Snapshot snapshot,
+ Document::Ptr symbolDocument,
Symbol *symbol)
- : workingCopy(workingCopy), snapshot(snapshot), symbol(symbol)
+ : workingCopy(workingCopy), snapshot(snapshot), symbolDocument(symbolDocument), symbol(symbol)
{ }
QList<Usage> operator()(const QString &fileName)
@@ -175,6 +177,7 @@ QList<int> CppFindReferences::references(Symbol *symbol,
static void find_helper(QFutureInterface<Usage> &future,
const CppTools::CppModelManagerInterface::WorkingCopy workingCopy,
Snapshot snapshot,
+ Document::Ptr symbolDocument,
Symbol *symbol)
{
QTime tm;
@@ -204,7 +207,7 @@ static void find_helper(QFutureInterface<Usage> &future,
future.setProgressRange(0, files.size());
- ProcessFile process(workingCopy, snapshot, symbol);
+ ProcessFile process(workingCopy, snapshot, symbolDocument, symbol);
UpdateUI reduce(&future);
QtConcurrent::blockingMappedReduced<QList<Usage> > (files, process, reduce);
@@ -212,17 +215,17 @@ static void find_helper(QFutureInterface<Usage> &future,
future.setProgressValue(files.size());
}
-void CppFindReferences::findUsages(Symbol *symbol)
+void CppFindReferences::findUsages(Document::Ptr symbolDocument, Symbol *symbol)
{
Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchOnly);
connect(search, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem)));
- findAll_helper(symbol);
+ findAll_helper(symbolDocument, symbol);
}
-void CppFindReferences::renameUsages(Symbol *symbol)
+void CppFindReferences::renameUsages(Document::Ptr symbolDocument, Symbol *symbol)
{
if (const Identifier *id = symbol->identifier()) {
const QString textToReplace = QString::fromUtf8(id->chars(), id->size());
@@ -236,11 +239,11 @@ void CppFindReferences::renameUsages(Symbol *symbol)
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
- findAll_helper(symbol);
+ findAll_helper(symbolDocument, symbol);
}
}
-void CppFindReferences::findAll_helper(Symbol *symbol)
+void CppFindReferences::findAll_helper(Document::Ptr symbolDocument, Symbol *symbol)
{
if (! (symbol && symbol->identifier()))
return;
@@ -254,7 +257,7 @@ void CppFindReferences::findAll_helper(Symbol *symbol)
QFuture<Usage> result;
- result = QtConcurrent::run(&find_helper, workingCopy, snapshot, symbol);
+ result = QtConcurrent::run(&find_helper, workingCopy, snapshot, symbolDocument, symbol);
m_watcher.setFuture(result);
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching..."),