More robustness in reading .cbp files

Instead of choosing the first one, choose the most recently modified one.
Also smallish fix to the title if no .cbp file exists

Task-Number: QTCREATORBUG-6553
Task-Number: QTCREATORBUG-6532
Change-Id: I34e2d7ca6d8242356e92099ed29ca0f0a4a11574
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
Daniel Teske
2011-11-16 14:15:54 +01:00
parent 20520dd073
commit 97dc1d4ab4
2 changed files with 16 additions and 3 deletions

View File

@@ -204,6 +204,11 @@ bool CMakeProject::parseCMakeLists()
CMakeBuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration(); CMakeBuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration();
QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory()); QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory());
if (cbpFile.isEmpty()) {
emit buildTargetsChanged();
return false;
}
// setFolderName // setFolderName
m_rootNode->setDisplayName(QFileInfo(cbpFile).completeBaseName()); m_rootNode->setDisplayName(QFileInfo(cbpFile).completeBaseName());
CMakeCbpParser cbpparser; CMakeCbpParser cbpparser;

View File

@@ -49,6 +49,7 @@
#include <QtCore/QtConcurrentRun> #include <QtCore/QtConcurrentRun>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtCore/QDateTime>
#include <QtGui/QFormLayout> #include <QtGui/QFormLayout>
#include <QtGui/QBoxLayout> #include <QtGui/QBoxLayout>
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
@@ -200,11 +201,18 @@ QString CMakeManager::findCbpFile(const QDir &directory)
// TODO the cbp file is named like the project() command in the CMakeList.txt file // TODO the cbp file is named like the project() command in the CMakeList.txt file
// so this method below could find the wrong cbp file, if the user changes the project() // so this method below could find the wrong cbp file, if the user changes the project()
// 2name // 2name
QDateTime t;
QString file;
foreach (const QString &cbpFile , directory.entryList()) { foreach (const QString &cbpFile , directory.entryList()) {
if (cbpFile.endsWith(QLatin1String(".cbp"))) if (cbpFile.endsWith(QLatin1String(".cbp"))) {
return directory.path() + QLatin1Char('/') + cbpFile; QFileInfo fi(directory.path() + QLatin1Char('/') + cbpFile);
if (t.isNull() || fi.lastModified() > t) {
file = directory.path() + QLatin1Char('/') + cbpFile;
t = fi.lastModified();
} }
return QString(); }
}
return file;
} }
// This code is duplicated from qtversionmanager // This code is duplicated from qtversionmanager