mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 01:04:13 +02:00
Fix the hash seed main() asks for having no effect
main() set QT_HASH_SEED=0 so that hashes, and so the XML a project is saved as, come out the same in every run. Qt reads that variable once, when the first hash is made, and that happens before main(): printed right after the qputenv(), QHashSeed::globalSeed() was a different random number in every run. The setting never took effect. QHashSeed::setDeterministicGlobalSeed() does what the variable was meant to, for every hash made from then on. The variable is kept for the processes QElectroTech starts. One visible effect: the PDF engine writes its fonts in QHash order, so --export-pdf of the same project gave different files from run to run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+7
-2
@@ -34,6 +34,7 @@
|
||||
#include <QApplication>
|
||||
#include <QDomImplementation>
|
||||
#include <QFont>
|
||||
#include <QHashSeed>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QStyleFactory>
|
||||
@@ -96,8 +97,12 @@ void qetLogMessageHandler(QtMsgType type,
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// before creating Application:
|
||||
// export environment-variable "QT_HASH_SEED" with value "0" to
|
||||
// disable radomisation for hashes in order to obtain "clean" XML-diffs:
|
||||
// disable randomisation for hashes in order to obtain "clean" XML-diffs,
|
||||
// and the same PDF for the same project (the PDF engine writes its fonts
|
||||
// in QHash order). Setting QT_HASH_SEED alone came too late: Qt reads it
|
||||
// once, when the first hash is made, and that happens before main().
|
||||
// The variable is still set for the processes QElectroTech starts.
|
||||
QHashSeed::setDeterministicGlobalSeed();
|
||||
qputenv("QT_HASH_SEED", "0");
|
||||
//Some setup, notably to use with QSetting.
|
||||
QCoreApplication::setOrganizationName("QElectroTech");
|
||||
|
||||
Reference in New Issue
Block a user