forked from qt-creator/qt-creator
make ProFileOption persist during the scan of an entire project
there is no point in throwing away and re-recreating invariant data over and over ... shaves off ~15% of the load time of Qt 4.6.
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
using namespace Qt4ProjectManager;
|
||||
using namespace Qt4ProjectManager::Internal;
|
||||
|
||||
ProFileReader::ProFileReader() : ProFileEvaluator(&m_option)
|
||||
ProFileReader::ProFileReader(ProFileOption *option) : ProFileEvaluator(option)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,14 +45,6 @@ ProFileReader::~ProFileReader()
|
||||
delete pf;
|
||||
}
|
||||
|
||||
void ProFileReader::setQtVersion(const QtVersion *qtVersion)
|
||||
{
|
||||
if (qtVersion)
|
||||
m_option.properties = qtVersion->versionInfo();
|
||||
else
|
||||
m_option.properties.clear();
|
||||
}
|
||||
|
||||
bool ProFileReader::readProFile(const QString &fileName)
|
||||
{
|
||||
//disable caching -> list of include files is not updated otherwise
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#define PROFILEREADER_H
|
||||
|
||||
#include "profileevaluator.h"
|
||||
#include "qtversionmanager.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMap>
|
||||
@@ -44,10 +43,9 @@ class ProFileReader : public QObject, public ProFileEvaluator
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ProFileReader();
|
||||
ProFileReader(ProFileOption *option);
|
||||
~ProFileReader();
|
||||
|
||||
void setQtVersion(const QtVersion *qtVersion);
|
||||
bool readProFile(const QString &fileName);
|
||||
QList<ProFile*> includeFiles() const;
|
||||
|
||||
@@ -67,7 +65,6 @@ private:
|
||||
private:
|
||||
QMap<QString, ProFile *> m_includeFiles;
|
||||
QList<ProFile *> m_proFiles;
|
||||
ProFileOption m_option;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -571,8 +571,7 @@ void MaemoRunConfiguration::updateTarget()
|
||||
return;
|
||||
}
|
||||
|
||||
QtVersion *qtVersion = qt4bc->qtVersion();
|
||||
ProFileReader *reader = proFileNode->createProFileReader();
|
||||
ProFileReader *reader = qt4Project->createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
@@ -582,7 +581,7 @@ void MaemoRunConfiguration::updateTarget()
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(m_proFilePath)) {
|
||||
delete reader;
|
||||
qt4Project->destroyProFileReader(reader);
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(tr(
|
||||
"Could not parse %1. The Maemo run configuration %2 "
|
||||
"can not be started.").arg(m_proFilePath).arg(name()));
|
||||
@@ -620,7 +619,7 @@ void MaemoRunConfiguration::updateTarget()
|
||||
target = QFileInfo(m_proFilePath).baseName();
|
||||
|
||||
m_executable = QDir::cleanPath(baseDir + QLatin1Char('/') + target);
|
||||
delete reader;
|
||||
qt4Project->destroyProFileReader(reader);
|
||||
}
|
||||
|
||||
emit targetInformationChanged();
|
||||
|
@@ -288,8 +288,7 @@ void S60DeviceRunConfiguration::updateTarget()
|
||||
emit targetInformationChanged();
|
||||
return;
|
||||
}
|
||||
QtVersion *qtVersion = qt4bc->qtVersion();
|
||||
ProFileReader *reader = proFileNode->createProFileReader();
|
||||
ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
@@ -299,7 +298,7 @@ void S60DeviceRunConfiguration::updateTarget()
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(m_proFilePath)) {
|
||||
delete reader;
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The QtS60 Device run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
|
||||
return;
|
||||
}
|
||||
@@ -346,7 +345,7 @@ void S60DeviceRunConfiguration::updateTarget()
|
||||
else
|
||||
m_target = QLatin1String("urel");
|
||||
m_baseFileName += QLatin1Char('_') + m_platform + QLatin1Char('_') + m_target;
|
||||
delete reader;
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
m_cachedTargetInformationValid = true;
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
@@ -135,8 +135,7 @@ void S60EmulatorRunConfiguration::updateTarget()
|
||||
emit targetInformationChanged();
|
||||
return;
|
||||
}
|
||||
QtVersion *qtVersion = qt4bc->qtVersion();
|
||||
ProFileReader *reader = proFileNode->createProFileReader();
|
||||
ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
@@ -146,11 +145,12 @@ void S60EmulatorRunConfiguration::updateTarget()
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(m_proFilePath)) {
|
||||
delete reader;
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The Qt for Symbian emulator run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
|
||||
return;
|
||||
}
|
||||
|
||||
QtVersion *qtVersion = qt4bc->qtVersion();
|
||||
QString baseDir = S60Manager::instance()->deviceForQtVersion(qtVersion).epocRoot;
|
||||
QString qmakeBuildConfig = "urel";
|
||||
if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild)
|
||||
@@ -165,7 +165,7 @@ void S60EmulatorRunConfiguration::updateTarget()
|
||||
QDir::cleanPath(baseDir + QLatin1Char('/') + target));
|
||||
m_executable += QLatin1String(".exe");
|
||||
|
||||
delete reader;
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
m_cachedTargetInformationValid = true;
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
@@ -560,10 +560,10 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
|
||||
if (filePaths.isEmpty())
|
||||
return;
|
||||
|
||||
ProFileReader *reader = m_qt4ProFileNode->createProFileReader();
|
||||
ProFileReader *reader = m_project->createProFileReader(m_qt4ProFileNode);
|
||||
if (!reader->readProFile(m_qt4ProFileNode->path())) {
|
||||
m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
|
||||
delete reader;
|
||||
m_project->destroyProFileReader(reader);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -576,7 +576,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
|
||||
|
||||
// Check for modified editors
|
||||
if (!saveModifiedEditors(m_projectFilePath)) {
|
||||
delete reader;
|
||||
m_project->destroyProFileReader(reader);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -661,7 +661,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
|
||||
|
||||
// save file
|
||||
save(includeFile);
|
||||
delete reader;
|
||||
m_project->destroyProFileReader(reader);
|
||||
}
|
||||
|
||||
void Qt4PriFileNode::save(ProFile *includeFile)
|
||||
@@ -805,10 +805,10 @@ void Qt4ProFileNode::scheduleUpdate()
|
||||
|
||||
void Qt4ProFileNode::update()
|
||||
{
|
||||
ProFileReader *reader = createProFileReader();
|
||||
ProFileReader *reader = m_project->createProFileReader(this);
|
||||
if (!reader->readProFile(m_projectFilePath)) {
|
||||
m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
|
||||
delete reader;
|
||||
m_project->destroyProFileReader(reader);
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
@@ -952,7 +952,7 @@ void Qt4ProFileNode::update()
|
||||
if (Qt4NodesWatcher *qt4Watcher = qobject_cast<Qt4NodesWatcher*>(watcher))
|
||||
emit qt4Watcher->proFileUpdated(this);
|
||||
|
||||
delete reader;
|
||||
m_project->destroyProFileReader(reader);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -1084,23 +1084,6 @@ QStringList Qt4ProFileNode::updateUiFiles()
|
||||
return toUpdate;
|
||||
}
|
||||
|
||||
ProFileReader *Qt4ProFileNode::createProFileReader() const
|
||||
{
|
||||
ProFileReader *reader = new ProFileReader();
|
||||
connect(reader, SIGNAL(errorFound(QString)),
|
||||
m_project, SLOT(proFileParseError(QString)));
|
||||
|
||||
Qt4BuildConfiguration *qt4bc = m_project->activeQt4BuildConfiguration();
|
||||
|
||||
QtVersion *version = qt4bc->qtVersion();
|
||||
if (version->isValid())
|
||||
reader->setQtVersion(version);
|
||||
|
||||
reader->setOutputDir(buildDir());
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
||||
Qt4ProFileNode *Qt4ProFileNode::createSubProFileNode(const QString &path)
|
||||
{
|
||||
Qt4ProFileNode *subProFileNode = new Qt4ProFileNode(m_project, path);
|
||||
|
@@ -198,9 +198,6 @@ public:
|
||||
|
||||
Qt4ProFileNode *findProFileFor(const QString &string);
|
||||
|
||||
//internal
|
||||
ProFileReader *createProFileReader() const;
|
||||
|
||||
public slots:
|
||||
void scheduleUpdate();
|
||||
void update();
|
||||
|
@@ -320,7 +320,8 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
|
||||
m_fileInfo(new Qt4ProjectFile(this, fileName, this)),
|
||||
m_isApplication(true),
|
||||
m_projectFiles(new Qt4ProjectFiles),
|
||||
m_lastActiveQt4BuildConfiguration(0)
|
||||
m_lastActiveQt4BuildConfiguration(0),
|
||||
m_proFileOption(0)
|
||||
{
|
||||
m_manager->registerProject(this);
|
||||
|
||||
@@ -855,6 +856,38 @@ void Qt4Project::proFileParseError(const QString &errorMessage)
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(errorMessage);
|
||||
}
|
||||
|
||||
ProFileReader *Qt4Project::createProFileReader(Qt4ProFileNode *qt4ProFileNode)
|
||||
{
|
||||
if (!m_proFileOption) {
|
||||
m_proFileOption = new ProFileOption;
|
||||
m_proFileOptionRefCnt = 0;
|
||||
|
||||
if (Qt4BuildConfiguration *qt4bc = activeQt4BuildConfiguration()) {
|
||||
QtVersion *version = qt4bc->qtVersion();
|
||||
if (version->isValid())
|
||||
m_proFileOption->properties = version->versionInfo();
|
||||
}
|
||||
}
|
||||
++m_proFileOptionRefCnt;
|
||||
|
||||
ProFileReader *reader = new ProFileReader(m_proFileOption);
|
||||
connect(reader, SIGNAL(errorFound(QString)),
|
||||
this, SLOT(proFileParseError(QString)));
|
||||
|
||||
reader->setOutputDir(qt4ProFileNode->buildDir());
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
||||
void Qt4Project::destroyProFileReader(ProFileReader *reader)
|
||||
{
|
||||
delete reader;
|
||||
if (!--m_proFileOptionRefCnt) {
|
||||
delete m_proFileOption;
|
||||
m_proFileOption = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Qt4ProFileNode *Qt4Project::rootProjectNode() const
|
||||
{
|
||||
return m_rootProjectNode;
|
||||
|
@@ -59,7 +59,7 @@ namespace CppTools {
|
||||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class ProFile;
|
||||
class ProFileOption;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
@@ -95,9 +95,6 @@ class Qt4ProjectFile : public Core::IFile
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
// needed for createProFileReader
|
||||
friend class Internal::Qt4RunConfiguration;
|
||||
|
||||
public:
|
||||
Qt4ProjectFile(Qt4Project *project, const QString &filePath, QObject *parent = 0);
|
||||
|
||||
@@ -196,6 +193,9 @@ public:
|
||||
virtual QStringList includePaths(const QString &fileName) const;
|
||||
virtual QStringList frameworkPaths(const QString &fileName) const;
|
||||
|
||||
Internal::ProFileReader *createProFileReader(Internal::Qt4ProFileNode *qt4ProFileNode);
|
||||
void destroyProFileReader(Internal::ProFileReader *reader);
|
||||
|
||||
signals:
|
||||
/// convenience signal, emitted if either the active buildconfiguration emits
|
||||
/// targetInformationChanged() or if the active build configuration changes
|
||||
@@ -262,6 +262,10 @@ private:
|
||||
|
||||
friend class Qt4ProjectFile;
|
||||
friend class Internal::Qt4ProjectConfigWidget;
|
||||
|
||||
// cached data during project rescan
|
||||
ProFileOption *m_proFileOption;
|
||||
int m_proFileOptionRefCnt;
|
||||
};
|
||||
|
||||
} // namespace Qt4ProjectManager
|
||||
|
@@ -572,7 +572,7 @@ void Qt4RunConfiguration::updateTarget()
|
||||
emit effectiveTargetInformationChanged();
|
||||
return;
|
||||
}
|
||||
ProFileReader *reader = proFileNode->createProFileReader();
|
||||
ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
@@ -582,7 +582,7 @@ void Qt4RunConfiguration::updateTarget()
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(m_proFilePath)) {
|
||||
delete reader;
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The Qt4 run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
|
||||
return;
|
||||
}
|
||||
@@ -636,7 +636,7 @@ void Qt4RunConfiguration::updateTarget()
|
||||
m_executable += QLatin1String(".exe");
|
||||
#endif
|
||||
|
||||
delete reader;
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
|
||||
m_cachedTargetInformationValid = true;
|
||||
|
||||
|
@@ -1205,8 +1205,9 @@ void QtVersion::updateToolChainAndMkspec() const
|
||||
|
||||
// qDebug()<<"mkspec for "<<qmakeCommand()<<" is "<<m_mkspec<<m_mkspecFullPath;
|
||||
|
||||
ProFileReader *reader = new ProFileReader();
|
||||
reader->setQtVersion(this);
|
||||
ProFileOption option;
|
||||
option.properties = versionInfo();
|
||||
ProFileReader *reader = new ProFileReader(&option);
|
||||
reader->setCumulative(false);
|
||||
reader->setParsePreAndPostFiles(false);
|
||||
reader->readProFile(m_mkspecFullPath + "/qmake.conf");
|
||||
|
Reference in New Issue
Block a user