From 6e478e0e3fcb9082106abc3b18c720ab56717773 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Sat, 3 Oct 2026 07:40:32 +1300 Subject: [PATCH] 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 --- sources/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sources/main.cpp b/sources/main.cpp index 5c8f78ab8..594e53747 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -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");