forked from qt-creator/qt-creator
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:
@@ -204,6 +204,11 @@ bool CMakeProject::parseCMakeLists()
|
||||
CMakeBuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration();
|
||||
QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory());
|
||||
|
||||
if (cbpFile.isEmpty()) {
|
||||
emit buildTargetsChanged();
|
||||
return false;
|
||||
}
|
||||
|
||||
// setFolderName
|
||||
m_rootNode->setDisplayName(QFileInfo(cbpFile).completeBaseName());
|
||||
CMakeCbpParser cbpparser;
|
||||
|
@@ -49,6 +49,7 @@
|
||||
#include <QtCore/QtConcurrentRun>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QBoxLayout>
|
||||
#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
|
||||
// so this method below could find the wrong cbp file, if the user changes the project()
|
||||
// 2name
|
||||
QDateTime t;
|
||||
QString file;
|
||||
foreach (const QString &cbpFile , directory.entryList()) {
|
||||
if (cbpFile.endsWith(QLatin1String(".cbp")))
|
||||
return directory.path() + QLatin1Char('/') + cbpFile;
|
||||
if (cbpFile.endsWith(QLatin1String(".cbp"))) {
|
||||
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
|
||||
|
Reference in New Issue
Block a user