OSDN Git Service

make use of QMutexLocker in QCoreApplication
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 17 May 2019 20:05:39 +0000 (20:05 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 17 May 2019 20:05:39 +0000 (20:05 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/kernel/qcoreapplication.cpp
src/core/kernel/qobjectdefs.h

index 2bd6024..451af57 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-class QMutexUnlocker
-{
-public:
-    inline explicit QMutexUnlocker(QMutex *m)
-        : mtx(m)
-    { }
-    inline ~QMutexUnlocker() { unlock(); }
-    inline void unlock() { if (mtx) mtx->unlock(); mtx = 0; }
-
-private:
-    Q_DISABLE_COPY(QMutexUnlocker)
-
-    QMutex *mtx;
-};
-
 QString QCoreApplicationPrivate::appName() const
 {
     QMutexLocker locker(QMutexPool::globalInstanceGet(&applicationName));
@@ -997,7 +982,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
     }
 
     // lock the post event mutex
-    data->postEventList.mutex.lock();
+    QMutexLocker locker(&data->postEventList.mutex);
 
     // if object has moved to another thread, follow it
     while (data != *pdata) {
@@ -1013,8 +998,6 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
         data->postEventList.mutex.lock();
     }
 
-    QMutexUnlocker locker(&data->postEventList.mutex);
-
     // if this is one of the compressible events, do compression
     if (receiver->d_func()->postedEvents
         && self && self->compressEvent(event, receiver, &data->postEventList)) {
index 2ed3386..5c0369f 100644 (file)
@@ -231,7 +231,6 @@ class QMetaEnum;
 class QMetaProperty;
 class QMetaClassInfo;
 
-
 class Q_CORE_EXPORT QGenericArgument
 {
 public:
@@ -270,7 +269,6 @@ public:
         {}
 };
 
-
 template <typename T>
 class QReturnArgument: public QGenericReturnArgument
 {