mirror of
https://github.com/QuasarApp/qca.git
synced 2025-05-11 02:09:33 +00:00
use qsrand/qrand for thread-safety
svn path=/trunk/kdesupport/qca/; revision=669694
This commit is contained in:
parent
89b1cd4de4
commit
ad90fab80c
@ -23,8 +23,6 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include "qcaprovider.h"
|
#include "qcaprovider.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#ifndef QCA_NO_SYSTEMSTORE
|
#ifndef QCA_NO_SYSTEMSTORE
|
||||||
# include "qca_systemstore.h"
|
# include "qca_systemstore.h"
|
||||||
@ -89,7 +87,7 @@ public:
|
|||||||
{
|
{
|
||||||
SecureArray buf(size);
|
SecureArray buf(size);
|
||||||
for(int n = 0; n < (int)buf.size(); ++n)
|
for(int n = 0; n < (int)buf.size(); ++n)
|
||||||
buf[n] = (char)rand();
|
buf[n] = (char)qrand();
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1081,11 +1079,11 @@ public:
|
|||||||
virtual void init()
|
virtual void init()
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
// avoid divide-by-zero
|
|
||||||
while(0 == now.time().msec())
|
uint t = now.toTime_t();
|
||||||
now = QDateTime::currentDateTime();
|
if(now.time().msec() > 0)
|
||||||
time_t t = now.toTime_t() / now.time().msec();
|
t /= now.time().msec();
|
||||||
srand(t);
|
qsrand(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int version() const
|
virtual int version() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user