forked from qt-creator/qt-creator
Always seed pseudo-random number generator
qrand() is used in several places, but it is only seeded in ToolSettings Change-Id: I72ed3b96315081384c63572566d31dea1a8f8b69 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
d101a3609c
commit
f4a9f56e3e
@@ -44,6 +44,7 @@
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
@@ -87,6 +88,7 @@ void CorePlugin::parseArguments(const QStringList &arguments)
|
||||
|
||||
bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||
parseArguments(arguments);
|
||||
const bool success = m_mainWindow->init(errorMessage);
|
||||
if (success) {
|
||||
|
||||
@@ -75,7 +75,6 @@ QWidget *ToolSettings::createPage(QWidget *parent)
|
||||
|
||||
static QString getUserFilePath(const QString &proposalFileName)
|
||||
{
|
||||
static bool seeded = false;
|
||||
QDir resourceDir(ICore::userResourcePath());
|
||||
if (!resourceDir.exists(QLatin1String("externaltools")))
|
||||
resourceDir.mkpath(QLatin1String("externaltools"));
|
||||
@@ -89,10 +88,6 @@ static QString getUserFilePath(const QString &proposalFileName)
|
||||
if (count > 15)
|
||||
return QString();
|
||||
// add random number
|
||||
if (!seeded) {
|
||||
seeded = true;
|
||||
qsrand(QTime::currentTime().msec());
|
||||
}
|
||||
int number = qrand() % 1000;
|
||||
tryPath = newFilePath + QString::number(number) + suffix;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user