summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Harju <mikko.harju@jolla.com>2013-09-13 13:38:46 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-28 14:59:56 +0100
commita578c2801a134a8d97e37ab9b6d9fd0a3093952a (patch)
tree2aba4f8943d4dda3689a93995ff55a0cc63aa884
parent7bf752b2b76c3c8f289d03801f2716b27480be67 (diff)
downloadqtwayland-a578c2801a134a8d97e37ab9b6d9fd0a3093952a.tar.gz
qtwayland-a578c2801a134a8d97e37ab9b6d9fd0a3093952a.tar.bz2
qtwayland-a578c2801a134a8d97e37ab9b6d9fd0a3093952a.zip
Support that clients queue up more than three buffers.
Though it is wrongful behavior on the clients part, a client should not be allowed to crash the compositor simply by posting it an extra buffer. Change-Id: Ia8ba0bbfc63273b0af13b81fbb9a74328289face Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp16
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface_p.h4
2 files changed, 12 insertions, 8 deletions
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index 9e07ba91..00a69d28 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -88,9 +88,6 @@ Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor)
, m_isCursorSurface(false)
{
wl_list_init(&m_frame_callback_list);
-
- for (int i = 0; i < buffer_pool_size; i++)
- m_bufferPool[i] = new SurfaceBuffer(this);
}
Surface::~Surface()
@@ -98,7 +95,7 @@ Surface::~Surface()
delete m_waylandSurface;
delete m_subSurface;
- for (int i = 0; i < buffer_pool_size; i++)
+ for (int i = 0; i < m_bufferPool.size(); i++)
delete m_bufferPool[i];
}
@@ -361,7 +358,7 @@ void Surface::setBackBuffer(SurfaceBuffer *buffer)
SurfaceBuffer *Surface::createSurfaceBuffer(struct ::wl_resource *buffer)
{
SurfaceBuffer *newBuffer = 0;
- for (int i = 0; i < Surface::buffer_pool_size; i++) {
+ for (int i = 0; i < m_bufferPool.size(); i++) {
if (!m_bufferPool[i]->isRegisteredWithBuffer()) {
newBuffer = m_bufferPool[i];
newBuffer->initialize(buffer);
@@ -369,7 +366,14 @@ SurfaceBuffer *Surface::createSurfaceBuffer(struct ::wl_resource *buffer)
}
}
- Q_ASSERT(newBuffer);
+ if (!newBuffer) {
+ newBuffer = new SurfaceBuffer(this);
+ newBuffer->initialize(buffer);
+ m_bufferPool.append(newBuffer);
+ if (m_bufferPool.size() > 3)
+ qWarning() << "Increased buffer pool size to" << m_bufferPool.size() << "for surface with title:" << title() << "className:" << className();
+ }
+
return newBuffer;
}
diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h
index 8f4aff00..92b49ed7 100644
--- a/src/compositor/wayland_wrapper/qwlsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlsurface_p.h
@@ -46,6 +46,7 @@
#include <private/qwlsurfacebuffer_p.h>
#include <QtCompositor/qwaylandsurface.h>
+#include <QtCore/QVector>
#include <QtCore/QRect>
#include <QtGui/QImage>
@@ -165,8 +166,7 @@ private:
QRegion m_inputRegion;
QRegion m_opaqueRegion;
- static const int buffer_pool_size = 3;
- SurfaceBuffer *m_bufferPool[buffer_pool_size];
+ QVector<SurfaceBuffer *> m_bufferPool;
QPointF m_position;
QSize m_size;