QtGui: replace some QMutexLockers with (new) qt_{scoped,unique}_lock()
In QImageReader, also replace a QMutex with a QBasicMutex, making the code similar to the corresponding code in QPicture. Change-Id: Ia1cd546eccd3662837762e506235e350b7a08647 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
72259e7186
commit
e8bca8e763
@ -150,7 +150,7 @@
|
||||
// factory loader
|
||||
#include <qcoreapplication.h>
|
||||
#include <private/qfactoryloader_p.h>
|
||||
#include <QMutexLocker>
|
||||
#include <QtCore/private/qlocking_p.h>
|
||||
|
||||
// for qt_getImageText
|
||||
#include <private/qimage_p.h>
|
||||
@ -186,8 +186,8 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
|
||||
QByteArray suffix;
|
||||
|
||||
#ifndef QT_NO_IMAGEFORMATPLUGIN
|
||||
static QMutex mutex;
|
||||
QMutexLocker locker(&mutex);
|
||||
static QBasicMutex mutex;
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
|
||||
typedef QMultiMap<int, QString> PluginKeyMap;
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "qregexp.h"
|
||||
#include "qregion.h"
|
||||
#include "qdebug.h"
|
||||
#include <QtCore/private/qlocking_p.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -1427,7 +1428,7 @@ void qt_init_picture_plugins()
|
||||
typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
|
||||
|
||||
static QBasicMutex mutex;
|
||||
QMutexLocker locker(&mutex);
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
static QFactoryLoader loader(QPictureFormatInterface_iid,
|
||||
QStringLiteral("/pictureformats"));
|
||||
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include <QtCore/private/qabstracteventdispatcher_p.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/private/qthread_p.h>
|
||||
#include <QtCore/private/qlocking_p.h>
|
||||
#include <QtCore/qdir.h>
|
||||
#include <QtCore/qlibraryinfo.h>
|
||||
#include <QtCore/qnumeric.h>
|
||||
@ -3305,7 +3306,7 @@ void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window)
|
||||
QFont QGuiApplication::font()
|
||||
{
|
||||
Q_ASSERT_X(QGuiApplicationPrivate::self, "QGuiApplication::font()", "no QGuiApplication instance");
|
||||
QMutexLocker locker(&applicationFontMutex);
|
||||
const auto locker = qt_scoped_lock(applicationFontMutex);
|
||||
initFontUnlocked();
|
||||
return *QGuiApplicationPrivate::app_font;
|
||||
}
|
||||
@ -3317,7 +3318,7 @@ QFont QGuiApplication::font()
|
||||
*/
|
||||
void QGuiApplication::setFont(const QFont &font)
|
||||
{
|
||||
QMutexLocker locker(&applicationFontMutex);
|
||||
auto locker = qt_unique_lock(applicationFontMutex);
|
||||
const bool emitChange = !QGuiApplicationPrivate::app_font
|
||||
|| (*QGuiApplicationPrivate::app_font != font);
|
||||
if (!QGuiApplicationPrivate::app_font)
|
||||
@ -4081,7 +4082,7 @@ void QGuiApplicationPrivate::notifyThemeChanged()
|
||||
sendApplicationPaletteChange();
|
||||
}
|
||||
if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) {
|
||||
QMutexLocker locker(&applicationFontMutex);
|
||||
const auto locker = qt_scoped_lock(applicationFontMutex);
|
||||
clearFontUnlocked();
|
||||
initFontUnlocked();
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include <QtCore/QThreadStorage>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/private/qlocking_p.h>
|
||||
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/private/qopengl_p.h>
|
||||
@ -1442,7 +1443,7 @@ QOpenGLContextGroup *QOpenGLContextGroup::currentContextGroup()
|
||||
|
||||
void QOpenGLContextGroupPrivate::addContext(QOpenGLContext *ctx)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
const auto locker = qt_scoped_lock(m_mutex);
|
||||
m_refs.ref();
|
||||
m_shares << ctx;
|
||||
}
|
||||
@ -1454,7 +1455,7 @@ void QOpenGLContextGroupPrivate::removeContext(QOpenGLContext *ctx)
|
||||
bool deleteObject = false;
|
||||
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
const auto locker = qt_scoped_lock(m_mutex);
|
||||
m_shares.removeOne(ctx);
|
||||
|
||||
if (ctx == m_context && !m_shares.isEmpty())
|
||||
@ -1502,7 +1503,7 @@ void QOpenGLContextGroupPrivate::cleanup()
|
||||
|
||||
void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
const auto locker = qt_scoped_lock(m_mutex);
|
||||
|
||||
const QList<QOpenGLSharedResource *> pending = m_pendingDeletion;
|
||||
m_pendingDeletion.clear();
|
||||
@ -1543,7 +1544,7 @@ void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx)
|
||||
QOpenGLSharedResource::QOpenGLSharedResource(QOpenGLContextGroup *group)
|
||||
: m_group(group)
|
||||
{
|
||||
QMutexLocker locker(&m_group->d_func()->m_mutex);
|
||||
const auto locker = qt_scoped_lock(m_group->d_func()->m_mutex);
|
||||
m_group->d_func()->m_sharedResources << this;
|
||||
}
|
||||
|
||||
@ -1559,7 +1560,7 @@ void QOpenGLSharedResource::free()
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker locker(&m_group->d_func()->m_mutex);
|
||||
const auto locker = qt_scoped_lock(m_group->d_func()->m_mutex);
|
||||
m_group->d_func()->m_sharedResources.removeOne(this);
|
||||
m_group->d_func()->m_pendingDeletion << this;
|
||||
|
||||
|
@ -228,7 +228,7 @@ TouchDevices::TouchDevices()
|
||||
*/
|
||||
QList<const QTouchDevice *> QTouchDevice::devices()
|
||||
{
|
||||
QMutexLocker lock(&devicesMutex);
|
||||
const auto locker = qt_scoped_lock(devicesMutex);
|
||||
return deviceList->list;
|
||||
}
|
||||
|
||||
@ -237,13 +237,13 @@ QList<const QTouchDevice *> QTouchDevice::devices()
|
||||
*/
|
||||
bool QTouchDevicePrivate::isRegistered(const QTouchDevice *dev)
|
||||
{
|
||||
QMutexLocker locker(&devicesMutex);
|
||||
const auto locker = qt_scoped_lock(devicesMutex);
|
||||
return deviceList->list.contains(dev);
|
||||
}
|
||||
|
||||
const QTouchDevice *QTouchDevicePrivate::deviceById(quint8 id)
|
||||
{
|
||||
QMutexLocker locker(&devicesMutex);
|
||||
const auto locker = qt_scoped_lock(devicesMutex);
|
||||
for (const QTouchDevice *dev : qAsConst(deviceList->list))
|
||||
if (QTouchDevicePrivate::get(const_cast<QTouchDevice *>(dev))->id == id)
|
||||
return dev;
|
||||
@ -255,7 +255,7 @@ const QTouchDevice *QTouchDevicePrivate::deviceById(quint8 id)
|
||||
*/
|
||||
void QTouchDevicePrivate::registerDevice(const QTouchDevice *dev)
|
||||
{
|
||||
QMutexLocker lock(&devicesMutex);
|
||||
const auto locker = qt_scoped_lock(devicesMutex);
|
||||
deviceList->list.append(dev);
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ void QTouchDevicePrivate::registerDevice(const QTouchDevice *dev)
|
||||
*/
|
||||
void QTouchDevicePrivate::unregisterDevice(const QTouchDevice *dev)
|
||||
{
|
||||
QMutexLocker lock(&devicesMutex);
|
||||
const auto locker = qt_scoped_lock(devicesMutex);
|
||||
deviceList->list.removeOne(dev);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user