diff options
author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-03-09 17:35:24 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-03-09 17:38:02 +0100 |
commit | 417a1c9f284fd4a8c66177eb9f2e65b36b910c15 (patch) | |
tree | d12f5686e4ef38ea4512296f2e91df8e03283160 /src | |
parent | e35a1e612a8817b3393967d7aea9e86564c210cc (diff) | |
download | qt-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')
-rw-r--r-- | src/libs/cplusplus/FindUsages.cpp | 18 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 4 | ||||
-rw-r--r-- | src/plugins/cpptools/cppfindreferences.cpp | 19 | ||||
-rw-r--r-- | src/plugins/cpptools/cppfindreferences.h | 6 | ||||
-rw-r--r-- | src/plugins/cpptools/cppmodelmanager.cpp | 8 | ||||
-rw-r--r-- | src/plugins/cpptools/cppmodelmanager.h | 4 | ||||
-rw-r--r-- | src/plugins/cpptools/cppmodelmanagerinterface.h | 4 |
7 files changed, 28 insertions, 35 deletions
diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp index 58c43ed721..a7554a14c1 100644 --- a/src/libs/cplusplus/FindUsages.cpp +++ b/src/libs/cplusplus/FindUsages.cpp @@ -465,24 +465,14 @@ bool FindUsages::visit(SimpleDeclarationAST *ast) bool FindUsages::visit(ObjCSelectorAST *ast) { -#if 1 - const Identifier *id = ast->name->identifier(); - if (id == _id) { - LookupContext context = currentContext(ast); - const QList<Symbol *> candidates = context.resolve(ast->name); - reportResult(ast->firstToken(), candidates); - } -#else - for (ObjCSelectorArgumentListAST *iter = ast->selector_argument_list; iter; - iter = iter->next) { - const Identifier *id = identifier(iter->value->name_token); + if (ast->name) { + const Identifier *id = ast->name->identifier(); if (id == _id) { - LookupContext context = currentContext(iter->value); + LookupContext context = currentContext(ast); const QList<Symbol *> candidates = context.resolve(ast->name); - reportResult(iter->value->name_token, candidates); + reportResult(ast->firstToken(), candidates); } } -#endif return false; } diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 899a8c1a75..83396edc06 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -903,7 +903,7 @@ const Macro *CPPEditor::findCanonicalMacro(const QTextCursor &cursor, void CPPEditor::findUsages() { if (Symbol *canonicalSymbol = markSymbols()) { - m_modelManager->findUsages(canonicalSymbol); + m_modelManager->findUsages(m_lastSemanticInfo.doc, canonicalSymbol); } else if (const Macro *macro = findCanonicalMacro(textCursor(), m_lastSemanticInfo.doc)) { m_modelManager->findMacroUsages(*macro); } @@ -954,7 +954,7 @@ void CPPEditor::renameUsagesNow() this, SLOT(hideRenameNotification())); } - m_modelManager->renameUsages(canonicalSymbol); + m_modelManager->renameUsages(m_lastSemanticInfo.doc, canonicalSymbol); } } } 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..."), diff --git a/src/plugins/cpptools/cppfindreferences.h b/src/plugins/cpptools/cppfindreferences.h index 06ad73fc53..74ede972e2 100644 --- a/src/plugins/cpptools/cppfindreferences.h +++ b/src/plugins/cpptools/cppfindreferences.h @@ -64,8 +64,8 @@ Q_SIGNALS: void changed(); public: - void findUsages(CPlusPlus::Symbol *symbol); - void renameUsages(CPlusPlus::Symbol *symbol); + void findUsages(CPlusPlus::Document::Ptr symbolDocument,CPlusPlus::Symbol *symbol); + void renameUsages(CPlusPlus::Document::Ptr symbolDocument,CPlusPlus::Symbol *symbol); void findMacroUses(const CPlusPlus::Macro ¯o); @@ -76,7 +76,7 @@ private Q_SLOTS: void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items); private: - void findAll_helper(CPlusPlus::Symbol *symbol); + void findAll_helper(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol); private: QPointer<CppModelManagerInterface> _modelManager; diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 0fb58e93dc..069b8e6c9d 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -733,16 +733,16 @@ QList<int> CppModelManager::references(CPlusPlus::Symbol *symbol, return m_findReferences->references(LookupContext::canonicalSymbol(symbol, glo.data()), doc, snapshot); } -void CppModelManager::findUsages(CPlusPlus::Symbol *symbol) +void CppModelManager::findUsages(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol) { if (symbol->identifier()) - m_findReferences->findUsages(symbol); + m_findReferences->findUsages(symbolDocument, symbol); } -void CppModelManager::renameUsages(CPlusPlus::Symbol *symbol) +void CppModelManager::renameUsages(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol) { if (symbol->identifier()) - m_findReferences->renameUsages(symbol); + m_findReferences->renameUsages(symbolDocument, symbol); } void CppModelManager::findMacroUsages(const CPlusPlus::Macro ¯o) diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 96e7ba4f01..c6369f10f2 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -120,8 +120,8 @@ public: CPlusPlus::Document::Ptr doc, const CPlusPlus::Snapshot &snapshot); - virtual void findUsages(CPlusPlus::Symbol *symbol); - virtual void renameUsages(CPlusPlus::Symbol *symbol); + virtual void findUsages(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol); + virtual void renameUsages(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol); virtual void findMacroUsages(const CPlusPlus::Macro ¯o); diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h index 4543825122..a08d874252 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.h +++ b/src/plugins/cpptools/cppmodelmanagerinterface.h @@ -121,8 +121,8 @@ public: CPlusPlus::Document::Ptr doc, const CPlusPlus::Snapshot &snapshot) = 0; - virtual void renameUsages(CPlusPlus::Symbol *symbol) = 0; - virtual void findUsages(CPlusPlus::Symbol *symbol) = 0; + virtual void renameUsages(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol) = 0; + virtual void findUsages(CPlusPlus::Document::Ptr symbolDocument, CPlusPlus::Symbol *symbol) = 0; virtual void findMacroUsages(const CPlusPlus::Macro ¯o) = 0; |