aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/FUNDING.yml2
-rw-r--r--CHANGELOG.md9
-rw-r--r--README.md2
-rw-r--r--singleapplication.cpp14
4 files changed, 23 insertions, 4 deletions
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 890d6e5..3ca4d97 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1 +1 @@
-custom: https://monzo.me/itaygrudev/5.00?d=SingleApplication # Replace with a single custom sponsorship URL
+github: itay-grudev
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45c197e..36f1e26 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,15 @@
Changelog
=========
+__3.0.19__
+----------
+
+* Fixed code warning for depricated functions in Qt 5.10 related to `QTime` and `qrand()`.
+
+ _Hennadii Chernyshchyk_
+ _Anton Filimonov_
+ _Jonas Kvinge_
+
__3.0.18__
----------
diff --git a/README.md b/README.md
index 5d60986..fa60057 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
SingleApplication
=================
+![CI](https://github.com/itay-grudev/SingleApplication/workflows/CI:%20Build%20Test/badge.svg)
+
This is a replacement of the QtSingleApplication for `Qt5`.
Keeps the Primary Instance of your Application and kills each subsequent
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 <QtCore/QTime>
+#include <QtCore/QElapsedTimer>
#include <QtCore/QThread>
-#include <QtCore/QDateTime>
#include <QtCore/QByteArray>
#include <QtCore/QSharedMemory>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+#include <QtCore/QRandomGenerator>
+#else
+#include <QtCore/QDateTime>
+#endif
#include "singleapplication.h"
#include "singleapplication_p.h"
@@ -82,7 +86,7 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
}
InstancesInfo* inst = static_cast<InstancesInfo*>( 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<uint>::max() );
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) );
+#endif
}
if( inst->primary == false) {