[LyX/master] Address another deprecation warning.

Juergen Spitzmueller spitz at lyx.org
Fri Mar 12 09:05:25 UTC 2021


commit 26459a2cf5c434d8d7c0fa58b05770858776033f
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Fri Mar 12 10:10:33 2021 +0100

    Address another deprecation warning.
    
    One left to go.
---
 src/frontends/qt/GuiApplication.cpp     |    8 +++++++-
 src/support/ConsoleApplicationPrivate.h |    7 +++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index 392c4b2..0ed875f 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -106,6 +106,9 @@
 #include <QObject>
 #include <QPainter>
 #include <QPixmap>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
+#include <QRandomGenerator>
+#endif
 #include <QRegExp>
 #include <QSessionManager>
 #include <QSettings>
@@ -1085,8 +1088,11 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
 	setDesktopFileName(lyx_package);
 #endif
 
-	// FIXME Deprecated. Should use QRandomGenerator since 5.10
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
+	QRandomGenerator(QDateTime::currentDateTime().toTime_t());
+#else
 	qsrand(QDateTime::currentDateTime().toTime_t());
+#endif
 
 	// Install LyX translator for missing Qt translations
 	installTranslator(&d->gui_trans_);
diff --git a/src/support/ConsoleApplicationPrivate.h b/src/support/ConsoleApplicationPrivate.h
index 74aa161..097a02d 100644
--- a/src/support/ConsoleApplicationPrivate.h
+++ b/src/support/ConsoleApplicationPrivate.h
@@ -16,6 +16,9 @@
 #include <QCoreApplication>
 #include <QDateTime>
 #include <QTimer>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
+#include <QRandomGenerator>
+#endif
 
 #include <string>
 
@@ -38,7 +41,11 @@ public:
 		setOrganizationDomain("lyx.org");
 		setApplicationName(toqstr(app));
 
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
+		QRandomGenerator(QDateTime::currentDateTime().toTime_t());
+#else
 		qsrand(QDateTime::currentDateTime().toTime_t());
+#endif
 	}
 	int execute()
 	{


More information about the lyx-cvs mailing list