diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 09cd788c61..ba27fb355b 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -965,14 +965,16 @@ void QMovie::setScaledSize(const QSize &size) QList QMovie::supportedFormats() { QList list = QImageReader::supportedImageFormats(); - QMutableListIterator it(list); + QBuffer buffer; buffer.open(QIODevice::ReadOnly); - while (it.hasNext()) { - QImageReader reader(&buffer, it.next()); - if (!reader.supportsAnimation()) - it.remove(); - } + + const auto doesntSupportAnimation = + [&buffer](const QByteArray &format) { + return !QImageReader(&buffer, format).supportsAnimation(); + }; + + list.erase(std::remove_if(list.begin(), list.end(), doesntSupportAnimation), list.end()); return list; }