Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Friedrich W. H. Kossebau
kdevelop
Commits
03bc7df8
Commit
03bc7df8
authored
Dec 21, 2019
by
Friedrich W. H. Kossebau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port away from deprecated qsrand() & qrand()
GIT_SILENT
parent
91112821
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
6 deletions
+64
-6
kdevplatform/language/duchain/duchain.cpp
kdevplatform/language/duchain/duchain.cpp
+7
-0
kdevplatform/shell/sessioncontroller.cpp
kdevplatform/shell/sessioncontroller.cpp
+8
-0
kdevplatform/shell/workingsetcontroller.cpp
kdevplatform/shell/workingsetcontroller.cpp
+12
-1
kdevplatform/util/tests/test_foregroundlock.cpp
kdevplatform/util/tests/test_foregroundlock.cpp
+10
-0
plugins/genericprojectmanager/tests/test_projectload.cpp
plugins/genericprojectmanager/tests/test_projectload.cpp
+18
-4
plugins/qmljs/duchain/tests/test_qmljscontexts.cpp
plugins/qmljs/duchain/tests/test_qmljscontexts.cpp
+9
-1
No files found.
kdevplatform/language/duchain/duchain.cpp
View file @
03bc7df8
...
...
@@ -30,6 +30,9 @@
#include <QStandardPaths>
#include <QMutex>
#include <QTimer>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
#include <interfaces/idocumentcontroller.h>
#include <interfaces/icore.h>
...
...
@@ -1064,7 +1067,11 @@ unloadContexts:
checkContextsCount
=
percentageOfContexts
;
if
(
visitor
.
checkContexts
.
size
()
>
(
int
)
checkContextsCount
)
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
startPos
=
QRandomGenerator
::
global
()
->
bounded
(
visitor
.
checkContexts
.
size
()
-
checkContextsCount
);
#else
startPos
=
qrand
()
%
(
visitor
.
checkContexts
.
size
()
-
checkContextsCount
);
#endif
int
endPos
=
startPos
+
maxFinalCleanupCheckContexts
;
if
(
endPos
>
visitor
.
checkContexts
.
size
())
...
...
kdevplatform/shell/sessioncontroller.cpp
View file @
03bc7df8
...
...
@@ -123,7 +123,9 @@ public:
void
newSession
()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand
(
QDateTime
::
currentDateTimeUtc
().
toTime_t
());
#endif
Session
*
session
=
new
Session
(
QUuid
::
createUuid
().
toString
()
);
KProcess
::
startDetached
(
ShellExtension
::
getInstance
()
->
executableFilePath
(),
QStringList
()
<<
QStringLiteral
(
"-s"
)
<<
session
->
id
().
toString
()
<<
standardArguments
());
...
...
@@ -415,7 +417,9 @@ Session* SessionController::createSession( const QString& name )
if
(
name
.
startsWith
(
QLatin1Char
(
'{'
)))
{
s
=
new
Session
(
QUuid
(
name
).
toString
(),
this
);
}
else
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand
(
QDateTime
::
currentDateTimeUtc
().
toTime_t
());
#endif
s
=
new
Session
(
QUuid
::
createUuid
().
toString
(),
this
);
s
->
setName
(
name
);
}
...
...
@@ -502,7 +506,9 @@ QString SessionController::cloneSession( const QString& nameOrid )
Q_D
(
SessionController
);
Session
*
origSession
=
session
(
nameOrid
);
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand
(
QDateTime
::
currentDateTimeUtc
().
toTime_t
());
#endif
QUuid
id
=
QUuid
::
createUuid
();
auto
copyJob
=
KIO
::
copy
(
QUrl
::
fromLocalFile
(
sessionDirectory
(
origSession
->
id
().
toString
())),
QUrl
::
fromLocalFile
(
sessionDirectory
(
id
.
toString
())));
...
...
@@ -665,7 +671,9 @@ QString SessionController::showSessionChooserDialog(const QString& headerText, b
const
QString
selectedSessionId
=
selected
.
sibling
(
selected
.
row
(),
0
).
data
().
toString
();
if
(
selectedSessionId
.
isEmpty
())
{
// "Create New Session" item selected, return a fresh UUID
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand
(
QDateTime
::
currentDateTimeUtc
().
toTime_t
());
#endif
return
QUuid
::
createUuid
().
toString
();
}
return
selectedSessionId
;
...
...
kdevplatform/shell/workingsetcontroller.cpp
View file @
03bc7df8
...
...
@@ -20,6 +20,9 @@
#include <QTimer>
#include <QVBoxLayout>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
#include "mainwindow.h"
#include "partdocument.h"
...
...
@@ -105,8 +108,16 @@ const QString WorkingSetController::makeSetId(const QString& prefix) const
{
QString
newId
;
const
uint
maxRetries
=
10
;
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
auto
*
randomGenerator
=
QRandomGenerator
::
global
();
#endif
for
(
uint
retry
=
2
;
retry
<=
maxRetries
;
retry
++
)
{
newId
=
QStringLiteral
(
"%1_%2"
).
arg
(
prefix
).
arg
(
qrand
()
%
10000000
);
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
const
auto
random
=
randomGenerator
->
bounded
(
10000000
);
#else
const
auto
random
=
qrand
()
%
10000000
;
#endif
newId
=
QStringLiteral
(
"%1_%2"
).
arg
(
prefix
).
arg
(
random
);
WorkingSetIconParameters
params
(
newId
);
for
(
WorkingSet
*
set
:
m_workingSets
)
{
if
(
set
->
isEmpty
())
{
...
...
kdevplatform/util/tests/test_foregroundlock.cpp
View file @
03bc7df8
...
...
@@ -21,6 +21,9 @@
#include <QTest>
#include <QThread>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
#include "../foregroundlock.h"
...
...
@@ -38,11 +41,18 @@ public:
void
run
()
override
{
ForegroundLock
lock
(
false
);
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
auto
*
randomGenerator
=
QRandomGenerator
::
global
();
#endif
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
if
(
lock
.
tryLock
())
{
lock
.
unlock
();
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QThread
::
usleep
(
randomGenerator
->
bounded
(
20
));
#else
QThread
::
usleep
(
qrand
()
%
20
);
#endif
}
}
};
...
...
plugins/genericprojectmanager/tests/test_projectload.cpp
View file @
03bc7df8
...
...
@@ -24,6 +24,9 @@
#include <QProcess>
#include <QTemporaryDir>
#include <QDebug>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
#include <tests/autotestshell.h>
#include <tests/testcore.h>
...
...
@@ -99,10 +102,16 @@ bool createFile(const QString& path)
return
false
;
}
f
.
write
(
QByteArray
::
number
(
qrand
()));
f
.
write
(
QByteArray
::
number
(
qrand
()));
f
.
write
(
QByteArray
::
number
(
qrand
()));
f
.
write
(
QByteArray
::
number
(
qrand
()));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
auto
*
randomGenerator
=
QRandomGenerator
::
global
();
#endif
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
f
.
write
(
QByteArray
::
number
(
randomGenerator
->
generate
()));
#else
f
.
write
(
QByteArray
::
number
(
qrand
()));
#endif
}
if
(
!
f
.
flush
())
{
qWarning
()
<<
f
.
errorString
()
<<
path
;
...
...
@@ -116,8 +125,13 @@ bool createFile(const QString& path)
bool
writeRandomStructure
(
QString
path
,
int
files
)
{
QDir
p
(
path
);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
const
QString
name
=
QString
::
number
(
QRandomGenerator
::
global
()
->
generate
());
if
(
QRandomGenerator
::
global
()
->
bounded
(
5
)
<
1
)
{
#else
QString
name
=
QString
::
number
(
qrand
());
if
(
qrand
()
<
RAND_MAX
/
5
)
{
#endif
if
(
!
p
.
mkdir
(
name
))
{
return
false
;
}
...
...
plugins/qmljs/duchain/tests/test_qmljscontexts.cpp
View file @
03bc7df8
...
...
@@ -30,6 +30,9 @@
#include <tests/testhelpers.h>
#include <QTest>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
QTEST_GUILESS_MAIN
(
TestContexts
)
...
...
@@ -54,7 +57,12 @@ void TestContexts::testFunctionContext()
QFETCH
(
RangeInRevision
,
argCtxRange
);
QFETCH
(
RangeInRevision
,
bodyCtxRange
);
const
IndexedString
file
(
QUrl
(
QStringLiteral
(
"file:///internal/%1-functionContext.js"
).
arg
(
qrand
())));
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
const
auto
random
=
QRandomGenerator
::
global
()
->
generate
();
#else
const
auto
random
=
qrand
();
#endif
const
IndexedString
file
(
QUrl
(
QStringLiteral
(
"file:///internal/%1-functionContext.js"
).
arg
(
random
)));
ParseSession
session
(
file
,
code
,
0
);
QVERIFY
(
session
.
ast
());
QCOMPARE
(
session
.
language
().
dialect
(),
QmlJS
::
Dialect
::
JavaScript
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment