From fcafcb340a3b6ffb9b7b9487d63b3ed499932642 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Mon, 17 Jan 2022 00:05:24 +0100 Subject: [PATCH] remove all instances of the type long (#4519) the long type has different sizes across operating systems and should not be used in the timeline an overflow could occur if the width in pixels multiplied by the total amount of milliseconds in the replay is larger than 2^31 which is easy enough considering with only 500 pixels width you'll reach this number with only 1.2 hours of replay (about 4 million millis), note that this would be windows exclusive as *nix uses 64 bits ~~qt-json's own repo suggests using qt5's implementation instead, testing revealed this is quite a bit faster, contrary to #3480~~ testing proved this to not be compatible with older qt versions servatrice uses the qthread usleep function which used to be protected but is now public cockatrice is not compatible with qt4 and hasn't been for a while --- cockatrice/src/replay_timeline_widget.cpp | 2 +- servatrice/src/servatrice.cpp | 22 +++++----------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/cockatrice/src/replay_timeline_widget.cpp b/cockatrice/src/replay_timeline_widget.cpp index bab6aad6..55abcaf0 100644 --- a/cockatrice/src/replay_timeline_widget.cpp +++ b/cockatrice/src/replay_timeline_widget.cpp @@ -62,7 +62,7 @@ void ReplayTimelineWidget::paintEvent(QPaintEvent * /* event */) void ReplayTimelineWidget::mousePressEvent(QMouseEvent *event) { - int newTime = static_cast((long)maxTime * (long)event->x() / width()); + int newTime = static_cast((qint64)maxTime * (qint64)event->x() / width()); newTime -= newTime % 200; // Time should always be a multiple of 200 if (newTime < currentTime) { currentTime = 0; diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index 8a25cf3e..25a862dc 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -212,24 +212,12 @@ Servatrice::~Servatrice() clientsLock.unlock(); // client destruction is asynchronous, wait for all clients to be gone - bool done = false; - - class SleeperThread : public QThread - { - public: - static void msleep(unsigned long msecs) - { - QThread::usleep(msecs); - } - }; - - do { - SleeperThread::msleep(10); - clientsLock.lockForRead(); + for (;;) { + QThread::usleep(10); + QReadLocker locker(&clientsLock); if (clients.isEmpty()) - done = true; - clientsLock.unlock(); - } while (!done); + break; + } prepareDestroy(); }