summaryrefslogtreecommitdiffstats
path: root/examples/network/threadedfortuneserver
diff options
context:
space:
mode:
Diffstat (limited to 'examples/network/threadedfortuneserver')
-rw-r--r--examples/network/threadedfortuneserver/fortuneserver.cpp4
-rw-r--r--examples/network/threadedfortuneserver/main.cpp1
2 files changed, 3 insertions, 2 deletions
diff --git a/examples/network/threadedfortuneserver/fortuneserver.cpp b/examples/network/threadedfortuneserver/fortuneserver.cpp
index 01b77e2aba..791ffc71f4 100644
--- a/examples/network/threadedfortuneserver/fortuneserver.cpp
+++ b/examples/network/threadedfortuneserver/fortuneserver.cpp
@@ -51,6 +51,8 @@
#include "fortuneserver.h"
#include "fortunethread.h"
+#include <QRandomGenerator>
+
#include <stdlib.h>
//! [0]
@@ -70,7 +72,7 @@ FortuneServer::FortuneServer(QObject *parent)
//! [1]
void FortuneServer::incomingConnection(qintptr socketDescriptor)
{
- QString fortune = fortunes.at(qrand() % fortunes.size());
+ QString fortune = fortunes.at(QRandomGenerator::global()->bounded(fortunes.size()));
FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
diff --git a/examples/network/threadedfortuneserver/main.cpp b/examples/network/threadedfortuneserver/main.cpp
index 3a54585fbc..fdacb28945 100644
--- a/examples/network/threadedfortuneserver/main.cpp
+++ b/examples/network/threadedfortuneserver/main.cpp
@@ -60,6 +60,5 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
Dialog dialog;
dialog.show();
- qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
return app.exec();
}