QWaylandShmBackingStore: replace a QLinkedList with std::list

...and mark the module QLinkedList-free.

QLinkedList is going to be deprecated.

Change-Id: Ieb9efef24cd8677edc1262f22b7c6d41b6376347
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
Marc Mutz 2019-06-04 20:11:32 +02:00
parent a582ec32d1
commit afe5668bb6
2 changed files with 10 additions and 9 deletions

View File

@ -249,7 +249,7 @@ QWaylandShmBuffer *QWaylandShmBackingStore::getBuffer(const QSize &size)
if (b->size() == size) {
return b;
} else {
mBuffers.removeOne(b);
mBuffers.remove(b);
if (mBackBuffer == b)
mBackBuffer = nullptr;
delete b;
@ -257,11 +257,11 @@ QWaylandShmBuffer *QWaylandShmBackingStore::getBuffer(const QSize &size)
}
}
static const int MAX_BUFFERS = 5;
if (mBuffers.count() < MAX_BUFFERS) {
static const size_t MAX_BUFFERS = 5;
if (mBuffers.size() < MAX_BUFFERS) {
QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format();
QWaylandShmBuffer *b = new QWaylandShmBuffer(mDisplay, size, format, waylandWindow()->scale());
mBuffers.prepend(b);
mBuffers.push_front(b);
return b;
}
return nullptr;
@ -300,9 +300,9 @@ void QWaylandShmBackingStore::resize(const QSize &size)
// ensure the new buffer is at the beginning of the list so next time getBuffer() will pick
// it if possible
if (mBuffers.first() != buffer) {
mBuffers.removeOne(buffer);
mBuffers.prepend(buffer);
if (mBuffers.front() != buffer) {
mBuffers.remove(buffer);
mBuffers.push_front(buffer);
}
if (windowDecoration() && window()->isVisible() && oldSizeInBytes != newSizeInBytes)

View File

@ -57,7 +57,8 @@
#include <QtGui/QImage>
#include <qpa/qplatformwindow.h>
#include <QMutex>
#include <QLinkedList>
#include <list>
QT_BEGIN_NAMESPACE
@ -116,7 +117,7 @@ private:
QWaylandShmBuffer *getBuffer(const QSize &size);
QWaylandDisplay *mDisplay = nullptr;
QLinkedList<QWaylandShmBuffer *> mBuffers;
std::list<QWaylandShmBuffer *> mBuffers;
QWaylandShmBuffer *mFrontBuffer = nullptr;
QWaylandShmBuffer *mBackBuffer = nullptr;
bool mPainting = false;