r24345 by jghali - Fix warnings related to qrand() deprecation

scribus-commit scribus-commit at lists.scribus.net
Tue Dec 22 00:43:57 UTC 2020


Author: jghali
Date: Tue Dec 22 00:43:57 2020
New Revision: 24345

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24345
Log:
Fix warnings related to qrand() deprecation

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24345&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Tue Dec 22 00:43:57 2020
@@ -21,6 +21,7 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <cstdlib>
 #include <memory>
 #include <utility>
 #include <sstream>
@@ -36,6 +37,7 @@
 #include <QPixmap>
 #include <QPointer>
 #include <QProgressBar>
+#include <QRandomGenerator>
 #include <QRegExp>
 #include <QtAlgorithms>
 #include <QTime>
@@ -16297,12 +16299,13 @@
 
 int ScribusDoc::addToInlineFrames(PageItem *item)
 {
-	int fIndex = qrand();
+	QRandomGenerator* randGen = QRandomGenerator::global();
+
+	int fIndex = randGen->bounded(RAND_MAX);
 	while (FrameItems.contains(fIndex))
-	{
-		fIndex = qrand();
-	}
+		fIndex = randGen->bounded(RAND_MAX);
 	item->inlineCharID = fIndex;
+
 	double lw = item->visualLineWidth() / 2.0;
 	item->setXYPos(lw, lw, true);
 	FrameItems.insert(fIndex, item);




More information about the scribus-commit mailing list