Commit ad33b33f authored by Lorenz Haas's avatar Lorenz Haas Committed by Eike Ziller

Core: Fix exit strategy

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

Change-Id: I62abe4701d6d919428266772867f4bc6c7c43759
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent db897f81
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment