forked from qt-creator/qt-creator
Vcs: fix potential issue in VcsBaseEditor::getTitleId()
In case the input list of filenames contains only empty item(s) then getTitleId() fails to return a valid result. It should return the workingDir or the revision. Change-Id: I697826446037e4b1e9f94c4c0c558336f8d44237 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
committed by
Tobias Hunger
parent
bd87b09072
commit
4e60001f83
@@ -1318,16 +1318,22 @@ QString VcsBaseEditor::getTitleId(const QString &workingDirectory,
|
|||||||
const QStringList &fileNames,
|
const QStringList &fileNames,
|
||||||
const QString &revision)
|
const QString &revision)
|
||||||
{
|
{
|
||||||
|
QStringList nonEmptyFileNames;
|
||||||
|
foreach (const QString& fileName, fileNames) {
|
||||||
|
if (!fileName.trimmed().isEmpty())
|
||||||
|
nonEmptyFileNames.append(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
QString rc;
|
QString rc;
|
||||||
switch (fileNames.size()) {
|
switch (nonEmptyFileNames.size()) {
|
||||||
case 0:
|
case 0:
|
||||||
rc = workingDirectory;
|
rc = workingDirectory;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
rc = fileNames.front();
|
rc = nonEmptyFileNames.front();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rc = fileNames.join(QLatin1String(", "));
|
rc = nonEmptyFileNames.join(QLatin1String(", "));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!revision.isEmpty()) {
|
if (!revision.isEmpty()) {
|
||||||
|
Reference in New Issue
Block a user