From 724efd7fdd49537f2aeb106b264cac0256f42817 Mon Sep 17 00:00:00 2001 From: Shatur95 Date: Fri, 27 Dec 2019 20:22:44 +0200 Subject: Fix obsolete code warnings --- singleapplication.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/singleapplication.cpp b/singleapplication.cpp index ba35c3a..8ff8747 100644 --- a/singleapplication.cpp +++ b/singleapplication.cpp @@ -20,11 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include +#include #include -#include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) +#include +#else +#include +#endif #include "singleapplication.h" #include "singleapplication_p.h" @@ -82,7 +86,7 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda } InstancesInfo* inst = static_cast( d->memory->data() ); - QTime time; + QElapsedTimer time; time.start(); // Make sure the shared memory block is initialised and in consistent state @@ -99,8 +103,12 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda d->memory->unlock(); // Random sleep here limits the probability of a collision between two racing apps +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + QThread::sleep( QRandomGenerator::global()->bounded( 8u, 18u ) ); +#else qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits::max() ); QThread::sleep( 8 + static_cast ( static_cast ( qrand() ) / RAND_MAX * 10 ) ); +#endif } if( inst->primary == false) { -- cgit v1.2.1