From be013eff5cdfd840880b5989f35f1542af615d16 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Wed, 9 Sep 2020 02:29:00 +0100 Subject: [PATCH] Mitigated QSharedMemory initialization failures Mitigated QSharedMemory initialization failures due to large amount of processes attempting to get hold of the shared memory block at the same time --- singleapplication.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/singleapplication.cpp b/singleapplication.cpp index d369aa1..0791096 100644 --- a/singleapplication.cpp +++ b/singleapplication.cpp @@ -55,6 +55,10 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda // block and QLocalServer d->genBlockServerName(); + // To mitigate QSharedMemory issues with large amount of processes + // attempting to attach at the same time + d->randomSleep(); + #ifdef Q_OS_UNIX // By explicitly attaching it and then deleting it we make sure that the // memory is deleted even after the process has crashed on Unix.