Seed Qt's random generator

LyX uses QTemporaryFile to create a unique temporary directory. This
temporary directory will consist of two random characters and the process
identifier (PID).

Currently, the two random characters are often the same because Qt's
random generator was not seeded. If there are a lot of lyx temporary
directories accumulated, the chance of failing to find a unique temporary
directory is (N/100)%.

The temporary directories can be left behind if either LyX crashes, or
when a file in the temporary directory is opened in another viewer when
LyX closes. This can be a pdf that is viewed in a reader that disallows
the file to be removed while viewing it.
This commit is contained in:
Vincent van Ravesteijn 2013-05-19 13:59:07 +02:00
parent 30f5187070
commit 327f7ed90d

View File

@ -946,6 +946,8 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
QCoreApplication::setOrganizationDomain("lyx.org");
QCoreApplication::setApplicationName(lyx_package);
qsrand(QDateTime::currentDateTime().toTime_t());
// Install translator for GUI elements.
installTranslator(&d->qt_trans_);