Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta

This commit is contained in:
hjk
2008-12-08 11:01:21 +01:00
5 changed files with 111 additions and 40 deletions

View File

@@ -62,11 +62,12 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>(); CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
if (modelmanager) { if (modelmanager) {
CppTools::CppModelManagerInterface::ProjectInfo *pinfo = modelmanager->projectInfo(this); CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
pinfo->includePaths = cbpparser.includeFiles(); pinfo.includePaths = cbpparser.includeFiles();
// TODO we only want C++ files, not all other stuff that might be in the project // TODO we only want C++ files, not all other stuff that might be in the project
pinfo->sourceFiles = m_files; pinfo.sourceFiles = m_files;
// TODO defines // TODO defines
modelmanager->updateProjectInfo(pinfo);
} }
} else { } else {
// TODO report error // TODO report error

View File

@@ -66,6 +66,7 @@
#include <Token.h> #include <Token.h>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QMutexLocker>
#include <QTime> #include <QTime>
#include <QDebug> #include <QDebug>
@@ -450,12 +451,25 @@ CppModelManager::CppModelManager(QObject *parent) :
CppModelManager::~CppModelManager() CppModelManager::~CppModelManager()
{ } { }
Document::Ptr CppModelManager::document(const QString &fileName) Document::Ptr CppModelManager::document(const QString &fileName) const
{ return m_documents.value(fileName); } { return m_documents.value(fileName); }
CppModelManager::DocumentTable CppModelManager::documents() CppModelManager::DocumentTable CppModelManager::documents() const
{ return m_documents; } { return m_documents; }
void CppModelManager::ensureUpdated()
{
QMutexLocker locker(&mutex);
if (! m_dirty)
return;
m_projectFiles = updateProjectFiles();
m_includePaths = updateIncludePaths();
m_frameworkPaths = updateFrameworkPaths();
m_definedMacros = updateDefinedMacros();
m_dirty = false;
}
QStringList CppModelManager::updateProjectFiles() const QStringList CppModelManager::updateProjectFiles() const
{ {
QStringList files; QStringList files;
@@ -527,8 +541,29 @@ QMap<QString, QByteArray> CppModelManager::buildWorkingCopyList()
void CppModelManager::updateSourceFiles(const QStringList &sourceFiles) void CppModelManager::updateSourceFiles(const QStringList &sourceFiles)
{ (void) refreshSourceFiles(sourceFiles); } { (void) refreshSourceFiles(sourceFiles); }
CppModelManager::ProjectInfo *CppModelManager::projectInfo(ProjectExplorer::Project *project) QList<CppModelManager::ProjectInfo> CppModelManager::projectInfos() const
{ return &m_projects[project]; } {
QMutexLocker locker(&mutex);
return m_projects.values();
}
CppModelManager::ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Project *project) const
{
QMutexLocker locker(&mutex);
return m_projects.value(project, ProjectInfo(project));
}
void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
{
QMutexLocker locker(&mutex);
if (! pinfo.isValid())
return;
m_projects.insert(pinfo.project, pinfo);
}
QFuture<void> CppModelManager::refreshSourceFiles(const QStringList &sourceFiles) QFuture<void> CppModelManager::refreshSourceFiles(const QStringList &sourceFiles)
{ {
@@ -691,13 +726,18 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
void CppModelManager::onProjectAdded(ProjectExplorer::Project *) void CppModelManager::onProjectAdded(ProjectExplorer::Project *)
{ {
QMutexLocker locker(&mutex);
m_dirty = true; m_dirty = true;
} }
void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project) void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
{ {
m_dirty = true; do {
m_projects.remove(project); QMutexLocker locker(&mutex);
m_dirty = true;
m_projects.remove(project);
} while (0);
GC(); GC();
} }
@@ -705,8 +745,15 @@ void CppModelManager::onSessionUnloaded()
{ {
if (m_core->progressManager()) { if (m_core->progressManager()) {
m_core->progressManager()->cancelTasks(CppTools::Constants::TASK_INDEX); m_core->progressManager()->cancelTasks(CppTools::Constants::TASK_INDEX);
m_dirty = true;
} }
do {
QMutexLocker locker(&mutex);
m_projects.clear();
m_dirty = true;
} while (0);
GC();
} }
void CppModelManager::parse(QFutureInterface<void> &future, void CppModelManager::parse(QFutureInterface<void> &future,

View File

@@ -40,6 +40,7 @@
#include <QMap> #include <QMap>
#include <QFutureInterface> #include <QFutureInterface>
#include <QMutex>
namespace Core { namespace Core {
class ICore; class ICore;
@@ -70,9 +71,13 @@ public:
virtual ~CppModelManager(); virtual ~CppModelManager();
virtual void updateSourceFiles(const QStringList &sourceFiles); virtual void updateSourceFiles(const QStringList &sourceFiles);
virtual ProjectInfo *projectInfo(ProjectExplorer::Project *project);
virtual CPlusPlus::Document::Ptr document(const QString &fileName); virtual QList<ProjectInfo> projectInfos() const;
virtual DocumentTable documents(); virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
virtual void updateProjectInfo(const ProjectInfo &pinfo);
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const;
virtual DocumentTable documents() const;
virtual void GC(); virtual void GC();
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles); QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
@@ -127,22 +132,12 @@ private:
return m_definedMacros; return m_definedMacros;
} }
void ensureUpdated();
QStringList updateProjectFiles() const; QStringList updateProjectFiles() const;
QStringList updateIncludePaths() const; QStringList updateIncludePaths() const;
QStringList updateFrameworkPaths() const; QStringList updateFrameworkPaths() const;
QByteArray updateDefinedMacros() const; QByteArray updateDefinedMacros() const;
void ensureUpdated() {
if (! m_dirty)
return;
m_projectFiles = updateProjectFiles();
m_includePaths = updateIncludePaths();
m_frameworkPaths = updateFrameworkPaths();
m_definedMacros = updateDefinedMacros();
m_dirty = false;
}
static void parse(QFutureInterface<void> &future, static void parse(QFutureInterface<void> &future,
CppPreprocessor *preproc, CppPreprocessor *preproc,
QStringList files); QStringList files);
@@ -166,6 +161,8 @@ private:
// project integration // project integration
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects; QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
mutable QMutex mutex;
enum { enum {
MAX_SELECTION_COUNT = 5 MAX_SELECTION_COUNT = 5
}; };

View File

@@ -38,6 +38,7 @@
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QPointer>
namespace ProjectExplorer { namespace ProjectExplorer {
class Project; class Project;
@@ -51,10 +52,29 @@ class CPPTOOLS_EXPORT CppModelManagerInterface
Q_OBJECT Q_OBJECT
public: public:
typedef QMap<QString, CPlusPlus::Document::Ptr> DocumentTable; typedef QMap<QString, CPlusPlus::Document::Ptr> DocumentTable; // ### remove me
struct ProjectInfo class ProjectInfo
{ {
public:
ProjectInfo()
{ }
ProjectInfo(QPointer<ProjectExplorer::Project> project)
: project(project)
{ }
operator bool() const
{ return ! project.isNull(); }
bool isValid() const
{ return ! project.isNull(); }
bool isNull() const
{ return project.isNull(); }
public: // attributes
QPointer<ProjectExplorer::Project> project;
QString projectPath; QString projectPath;
QByteArray defines; QByteArray defines;
QStringList sourceFiles; QStringList sourceFiles;
@@ -69,10 +89,12 @@ public:
virtual void GC() = 0; virtual void GC() = 0;
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0; virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
virtual CPlusPlus::Document::Ptr document(const QString &fileName) = 0; virtual CPlusPlus::Document::Ptr document(const QString &fileName) const = 0;
virtual DocumentTable documents() = 0; virtual DocumentTable documents() const = 0;
virtual ProjectInfo *projectInfo(ProjectExplorer::Project *project) = 0; virtual QList<ProjectInfo> projectInfos() const = 0;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
}; };
} // namespace CppTools } // namespace CppTools

View File

@@ -480,23 +480,27 @@ void Qt4Project::updateCodeModel()
files += m_projectFiles->files[SourceType]; files += m_projectFiles->files[SourceType];
files += m_projectFiles->generatedFiles[SourceType]; files += m_projectFiles->generatedFiles[SourceType];
CppTools::CppModelManagerInterface::ProjectInfo *pinfo = modelmanager->projectInfo(this); CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
if (pinfo->defines == predefinedMacros && if (pinfo.defines == predefinedMacros &&
pinfo->includePaths == allIncludePaths && pinfo.includePaths == allIncludePaths &&
pinfo->frameworkPaths == allFrameworkPaths && pinfo.frameworkPaths == allFrameworkPaths &&
pinfo->sourceFiles == files) { pinfo.sourceFiles == files) {
// Nothing to update... modelmanager->updateProjectInfo(pinfo);
} else { } else {
pinfo->defines = predefinedMacros; pinfo.defines = predefinedMacros;
// pinfo->defines += definedMacros; // ### FIXME: me // pinfo->defines += definedMacros; // ### FIXME: me
pinfo->includePaths = allIncludePaths; pinfo.includePaths = allIncludePaths;
pinfo->frameworkPaths = allFrameworkPaths; pinfo.frameworkPaths = allFrameworkPaths;
pinfo->sourceFiles = files; pinfo.sourceFiles = files;
modelmanager->updateProjectInfo(pinfo);
modelmanager->GC(); modelmanager->GC();
modelmanager->updateSourceFiles(pinfo->sourceFiles); modelmanager->updateSourceFiles(pinfo.sourceFiles);
} }
// update info
} }