diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-10 11:08:29 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-20 20:48:59 +0200 |
commit | 34fe9232dbf6a9fe58ebc4c7680bb67d2f642c40 (patch) | |
tree | d85afa295e882b84aa11c8861d6b85799c2f7e71 /src/gui/image | |
parent | 84e89c1e9e00d4fab576b876cfa80e92b5602982 (diff) |
Port from QAtomic::load() to loadRelaxed()
Semi-automated, just needed ~20 manual fixes:
$ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} +
$ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} +
It can be easily improved (e.g. for store check that there are no commas
after the opening parens). The most common offender is QLibrary::load,
and some code using std::atomic directly.
Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 8 | ||||
-rw-r--r-- | src/gui/image/qpicture.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 10 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 1d1b6d3c49..df8220a0c6 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -987,7 +987,7 @@ bool QIcon::isNull() const */ bool QIcon::isDetached() const { - return !d || d->ref.load() == 1; + return !d || d->ref.loadRelaxed() == 1; } /*! \internal @@ -1000,7 +1000,7 @@ void QIcon::detach() delete d; d = 0; return; - } else if (d->ref.load() != 1) { + } else if (d->ref.loadRelaxed() != 1) { QIconPrivate *x = new QIconPrivate(d->engine->clone()); if (!d->ref.deref()) delete d; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 917dde3b0f..61d32b0dec 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1082,10 +1082,10 @@ QImage::operator QVariant() const void QImage::detach() { if (d) { - if (d->is_cached && d->ref.load() == 1) + if (d->is_cached && d->ref.loadRelaxed() == 1) QImagePixmapCleanupHooks::executeImageHooks(cacheKey()); - if (d->ref.load() != 1 || d->ro_data) + if (d->ref.loadRelaxed() != 1 || d->ro_data) *this = copy(); if (d) @@ -4422,7 +4422,7 @@ qint64 QImage::cacheKey() const bool QImage::isDetached() const { - return d && d->ref.load() == 1; + return d && d->ref.loadRelaxed() == 1; } @@ -5087,7 +5087,7 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla return true; // No in-place conversion if we have to detach - if (ref.load() > 1 || !own_data) + if (ref.loadRelaxed() > 1 || !own_data) return false; InPlace_Image_Converter converter = qimage_inplace_converter_map[format][newFormat]; diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index fe1e4d2c9b..8548f1857e 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -235,7 +235,7 @@ void QPicture::detach() bool QPicture::isDetached() const { - return d_func()->ref.load() == 1; + return d_func()->ref.loadRelaxed() == 1; } /*! diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 399ad7453d..b6e41f16a5 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -262,7 +262,7 @@ QPixmap::QPixmap(const char * const xpm[]) QPixmap::~QPixmap() { - Q_ASSERT(!data || data->ref.load() >= 1); // Catch if ref-counting changes again + Q_ASSERT(!data || data->ref.loadRelaxed() >= 1); // Catch if ref-counting changes again } /*! @@ -910,7 +910,7 @@ void QPixmap::fill(const QColor &color) return; } - if (data->ref.load() == 1) { + if (data->ref.loadRelaxed() == 1) { // detach() will also remove this pixmap from caches, so // it has to be called even when ref == 1. detach(); @@ -1053,7 +1053,7 @@ QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap) bool QPixmap::isDetached() const { - return data && data->ref.load() == 1; + return data && data->ref.loadRelaxed() == 1; } /*! @@ -1523,10 +1523,10 @@ void QPixmap::detach() rasterData->image.detach(); } - if (data->is_cached && data->ref.load() == 1) + if (data->is_cached && data->ref.loadRelaxed() == 1) QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data()); - if (data->ref.load() != 1) { + if (data->ref.loadRelaxed() != 1) { *this = copy(); } ++data->detach_no; |