Core: Fix exit strategy

Fix break condition for a while loop and add some "const".

Change-Id: I62abe4701d6d919428266772867f4bc6c7c43759
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Lorenz Haas
2014-02-02 20:31:55 +01:00
committed by Eike Ziller
parent db897f8146
commit ad33b33ff1

View File

@@ -67,20 +67,20 @@ QWidget *ToolSettings::widget()
static QString getUserFilePath(const QString &proposalFileName)
{
QDir resourceDir(ICore::userResourcePath());
const QDir resourceDir(ICore::userResourcePath());
if (!resourceDir.exists(QLatin1String("externaltools")))
resourceDir.mkpath(QLatin1String("externaltools"));
QFileInfo fi(proposalFileName);
const QFileInfo fi(proposalFileName);
const QString &suffix = QLatin1String(".") + fi.completeSuffix();
const QString &newFilePath = ICore::userResourcePath()
+ QLatin1String("/externaltools/") + fi.baseName();
int count = 0;
QString tryPath = newFilePath + suffix;
while (QFile::exists(tryPath)) {
if (count > 15)
if (++count > 15)
return QString();
// add random number
int number = qrand() % 1000;
const int number = qrand() % 1000;
tryPath = newFilePath + QString::number(number) + suffix;
}
return tryPath;