diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index a960a4fe04c575db71010a3c687b969fef2bc77d..43a270f1f3a46c143403d60cca740be3c1a3391a 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -101,7 +101,7 @@ void CMakeManager::updateContextMenu(ProjectExplorer::Project *project, ProjectE void CMakeManager::runCMake() { - runCMake(ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject()); + runCMake(ProjectExplorer::ProjectExplorerPlugin::currentProject()); } void CMakeManager::runCMakeContextMenu() diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 34c44ec6ce1761d10d296ca00114c7742b0c0a07..c54f2ac5a064421cff3ed7bf4c464c1dacd9d345 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -2157,7 +2157,7 @@ TextEditor::IAssistInterface *CPPEditorWidget::createAssistInterface( QStringList includePaths; QStringList frameworkPaths; if (ProjectExplorer::Project *project = - ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject()) { + ProjectExplorer::ProjectExplorerPlugin::currentProject()) { includePaths = m_modelManager->projectInfo(project).includePaths; frameworkPaths = m_modelManager->projectInfo(project).frameworkPaths; } diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index 7c686adaaef92f1bfc4846d8767cde8752b5e34a..8adc6f9f1c0a7f6f277cda2bca36210a1d11d2e0 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -266,9 +266,7 @@ QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) co return m_headerSourceMapping.value(fi.absoluteFilePath()); const Core::MimeDatabase *mimeDatase = Core::ICore::mimeDatabase(); - ProjectExplorer::ProjectExplorerPlugin *explorer = - ProjectExplorer::ProjectExplorerPlugin::instance(); - ProjectExplorer::Project *project = (explorer ? explorer->currentProject() : 0); + ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject(); const FileType type = fileType(mimeDatase, fi); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index b58a2ac49d4a10314e5f95fffc5cbf0a75d69026..f95f953bbdcda65cd1c627694fe1980889289f52 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -499,7 +499,7 @@ public: bool DummyEngine::hasCapability(unsigned cap) const { // This can only be a first approximation of what to expect when running. - Project *project = ProjectExplorerPlugin::instance()->currentProject(); + Project *project = ProjectExplorerPlugin::currentProject(); if (!project) return 0; Target *target = project->activeTarget(); diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp index 4ebe27cc688432c1646c37bf3da5e2404ac1a265..ab700c6c1aa5faad5048fc5f72df9d54e916e032 100644 --- a/src/plugins/projectexplorer/currentprojectfind.cpp +++ b/src/plugins/projectexplorer/currentprojectfind.cpp @@ -69,13 +69,14 @@ QString CurrentProjectFind::displayName() const bool CurrentProjectFind::isEnabled() const { - return m_plugin->currentProject() != 0 && BaseFileFind::isEnabled(); + return ProjectExplorerPlugin::currentProject() != 0 && BaseFileFind::isEnabled(); } QVariant CurrentProjectFind::additionalParameters() const { - if (m_plugin->currentProject() && m_plugin->currentProject()->file()) - return qVariantFromValue(m_plugin->currentProject()->file()->fileName()); + Project *project = ProjectExplorerPlugin::currentProject(); + if (project && project->file()) + return qVariantFromValue(project->file()->fileName()); return QVariant(); } @@ -95,8 +96,8 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters, QString CurrentProjectFind::label() const { - QTC_ASSERT(m_plugin->currentProject(), return QString()); - return tr("Project '%1':").arg(m_plugin->currentProject()->displayName()); + QTC_ASSERT(ProjectExplorerPlugin::currentProject(), return QString()); + return tr("Project '%1':").arg(ProjectExplorerPlugin::currentProject()->displayName()); } void CurrentProjectFind::handleProjectChanged() diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index ac1fc6508d7dc71dd0ab1d68d02e857fa95bb70e..8ea8ee1978c209cf728534458f0be0a080e37138 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1347,15 +1347,16 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName return openedPro; } -Project *ProjectExplorerPlugin::currentProject() const +Project *ProjectExplorerPlugin::currentProject() { + Project *project = m_instance->d->m_currentProject; if (debug) { - if (d->m_currentProject) - qDebug() << "ProjectExplorerPlugin::currentProject returns " << d->m_currentProject->displayName(); + if (project) + qDebug() << "ProjectExplorerPlugin::currentProject returns " << project->displayName(); else qDebug() << "ProjectExplorerPlugin::currentProject returns 0"; } - return d->m_currentProject; + return project; } Node *ProjectExplorerPlugin::currentNode() const diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index faf9167e8171bcb1849341b7fe142b3fa2bc908e..6818c78502d066969eb3df5e4b9f99db10af20a1 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -84,7 +84,7 @@ public: SessionManager *session() const; - Project *currentProject() const; + static Project *currentProject(); Node *currentNode() const; void setCurrentFile(Project *project, const QString &file); diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index f70507f9ef0eee3005eda7530bcd13a934471ef9..9d5929cb48178edde81058a5bf34336f746fd68a 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -263,7 +263,7 @@ void ProjectTreeWidget::setAutoSynchronization(bool sync, bool syncNow) connect(m_explorer, SIGNAL(currentNodeChanged(ProjectExplorer::Node*, ProjectExplorer::Project*)), this, SLOT(setCurrentItem(ProjectExplorer::Node*, ProjectExplorer::Project*))); if (syncNow) - setCurrentItem(m_explorer->currentNode(), m_explorer->currentProject()); + setCurrentItem(m_explorer->currentNode(), ProjectExplorerPlugin::currentProject()); } else { disconnect(m_explorer, SIGNAL(currentNodeChanged(ProjectExplorer::Node*, ProjectExplorer::Project*)), this, SLOT(setCurrentItem(ProjectExplorer::Node*, ProjectExplorer::Project*))); @@ -354,7 +354,7 @@ void ProjectTreeWidget::initView() for (int i = 0; i < m_model->rowCount(sessionIndex); ++i) m_view->expand(m_model->index(i, 0, sessionIndex)); - setCurrentItem(m_explorer->currentNode(), m_explorer->currentProject()); + setCurrentItem(m_explorer->currentNode(), ProjectExplorerPlugin::currentProject()); } void ProjectTreeWidget::openItem(const QModelIndex &mainIndex) diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 3f334fd7a8f7e63140a8a6c1b5bf61eec724556d..e035ce703a1b6d157b1f994d43e323bb537ca2ee 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -820,7 +820,7 @@ Project *SessionManager::projectForFile(const QString &fileName) const const QList<Project *> &projectList = projects(); // Check current project first - Project *currentProject = ProjectExplorerPlugin::instance()->currentProject(); + Project *currentProject = ProjectExplorerPlugin::currentProject(); if (currentProject && projectContainsFile(currentProject, fileName)) return currentProject; @@ -856,7 +856,7 @@ QString SessionManager::currentSession() const void SessionManager::updateWindowTitle() { if (isDefaultSession(m_sessionName)) { - if (Project *currentProject = ProjectExplorerPlugin::instance()->currentProject()) + if (Project *currentProject = ProjectExplorerPlugin::currentProject()) ICore::editorManager()->setWindowTitleAddition(currentProject->displayName()); else ICore::editorManager()->setWindowTitleAddition(QString()); diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 94df655a5f10bba52992650004519d61642b751f..eeea3fe7f34c1185dcd6e21de35aa626c1699c84 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -185,7 +185,7 @@ void Qt4Manager::editorAboutToClose(Core::IEditor *editor) void Qt4Manager::updateVariable(const QByteArray &variable) { if (variable == kInstallBins) { - Qt4Project *qt4pro = qobject_cast<Qt4Project *>(projectExplorer()->currentProject()); + Qt4Project *qt4pro = qobject_cast<Qt4Project *>(ProjectExplorer::ProjectExplorerPlugin::currentProject()); if (!qt4pro) { Core::VariableManager::instance()->remove(kInstallBins); return; diff --git a/src/plugins/tasklist/taskfilefactory.cpp b/src/plugins/tasklist/taskfilefactory.cpp index d63ed182b11d652f150403378a5393c93aa5ad09..a0cb3195a93be0f0cd98208a5e5c30e2f0a361b7 100644 --- a/src/plugins/tasklist/taskfilefactory.cpp +++ b/src/plugins/tasklist/taskfilefactory.cpp @@ -73,8 +73,7 @@ QString TaskFileFactory::displayName() const Core::IFile *TaskFileFactory::open(const QString &fileName) { - ProjectExplorer::Project * context = - ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject(); + ProjectExplorer::Project *context = ProjectExplorer::ProjectExplorerPlugin::currentProject(); return open(context, fileName); } diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index f3ecd8a2405a072dc1725b119cb071e4241d8105..57fdecb5cfb469a64ed2c160b5c35c19a280a82a 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -398,8 +398,7 @@ void CallgrindToolPrivate::updateCostFormat() void CallgrindToolPrivate::handleFilterProjectCosts() { - ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); - ProjectExplorer::Project *pro = pe->currentProject(); + ProjectExplorer::Project *pro = ProjectExplorer::ProjectExplorerPlugin::currentProject(); QTC_ASSERT(pro, return) if (m_filterProjectCosts->isChecked()) { diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index b4670ffba7150e05d8af06f31614ab4d23535673..7e422dc87e2f3a50975c04e2217b9db48da46336 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -231,7 +231,6 @@ static inline QString displayNameOfEditor(const QString &fileName) void StateListener::slotStateChanged() { - const ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); Core::VcsManager *vcsManager = Core::ICore::vcsManager(); // Get the current file. Are we on a temporary submit editor indicated by @@ -280,7 +279,7 @@ void StateListener::slotStateChanged() } // Check for project, find the control Core::IVersionControl *projectControl = 0; - if (const ProjectExplorer::Project *currentProject = pe->currentProject()) { + if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject()) { state.currentProjectPath = currentProject->projectDirectory(); state.currentProjectName = currentProject->displayName(); projectControl = vcsManager->findVersionControlForDirectory(state.currentProjectPath, @@ -643,7 +642,7 @@ void VcsBasePlugin::createRepository() QTC_ASSERT(d->m_versionControl->supportsOperation(Core::IVersionControl::CreateRepositoryOperation), return); // Find current starting directory QString directory; - if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject()) + if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject()) directory = QFileInfo(currentProject->file()->fileName()).absolutePath(); // Prompt for a directory that is not under version control yet QMainWindow *mw = Core::ICore::mainWindow(); diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index e0362d003536adb1d6c2234437978593da4e7b71..1570f365af24b12d961511cc5b8bf1a145ff2280 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -770,18 +770,16 @@ QStringList VcsBaseSubmitEditor::currentProjectFiles(bool nativeSeparators, QStr if (name) name->clear(); - if (ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance()) { - if (const ProjectExplorer::Project *currentProject = pe->currentProject()) { - QStringList files = currentProject->files(ProjectExplorer::Project::ExcludeGeneratedFiles); - if (name) - *name = currentProject->displayName(); - if (nativeSeparators && !files.empty()) { - const QStringList::iterator end = files.end(); - for (QStringList::iterator it = files.begin(); it != end; ++it) - *it = QDir::toNativeSeparators(*it); - } - return files; + if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject()) { + QStringList files = currentProject->files(ProjectExplorer::Project::ExcludeGeneratedFiles); + if (name) + *name = currentProject->displayName(); + if (nativeSeparators && !files.empty()) { + const QStringList::iterator end = files.end(); + for (QStringList::iterator it = files.begin(); it != end; ++it) + *it = QDir::toNativeSeparators(*it); } + return files; } return QStringList(); }