summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@nokia.com>2012-06-05 15:41:59 +0200
committerJørgen Lind <jorgen.lind@nokia.com>2012-06-06 10:14:10 +0200
commit077067bc8f68a3146430b941ea0f0daa61781f91 (patch)
tree46502496fab3f8949f3c73e7e6af8df734d3c532
parent123efe5eb255cf0e2408dff3022cf3e0115a11e7 (diff)
A few fixes to prevent compositor crashes
If a client application exits abruptly while in direct rendering mode, the surface buffer could reference a null buffer. We now check for this before attempting to use such a surface buffer. It is also possible for WaylandSurfaceNode::preprocess to be called after WaylandSurfaceItem has called surfaceDestroyed, so now we check for a valid surface in preprocess as well. Change-Id: Ibca71349b7a24687944f8b6cd505941b580e0c2a Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com> Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
-rw-r--r--src/compositor/compositor_api/waylandsurfacenode.cpp10
-rw-r--r--src/compositor/wayland_wrapper/wlsurface.cpp18
-rw-r--r--src/compositor/wayland_wrapper/wlsurfacebuffer.cpp3
3 files changed, 19 insertions, 12 deletions
diff --git a/src/compositor/compositor_api/waylandsurfacenode.cpp b/src/compositor/compositor_api/waylandsurfacenode.cpp
index e6571751c..a4063ccb4 100644
--- a/src/compositor/compositor_api/waylandsurfacenode.cpp
+++ b/src/compositor/compositor_api/waylandsurfacenode.cpp
@@ -39,10 +39,12 @@ void WaylandSurfaceNode::preprocess()
{
QMutexLocker locker(WaylandSurfaceItem::mutex);
- //Update if the item is dirty and we haven't done an updateTexture for this frame
- if (m_item && m_item->m_damaged && !m_textureUpdated) {
- m_item->updateTexture();
- updateTexture();
+ if (m_item && m_item->surface()) {
+ //Update if the item is dirty and we haven't done an updateTexture for this frame
+ if (m_item->m_damaged && !m_textureUpdated) {
+ m_item->updateTexture();
+ updateTexture();
+ }
}
//Reset value for next frame: we have not done updatePaintNode yet
m_textureUpdated = false;
diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp
index 579c27bd1..ff13e017a 100644
--- a/src/compositor/wayland_wrapper/wlsurface.cpp
+++ b/src/compositor/wayland_wrapper/wlsurface.cpp
@@ -377,14 +377,16 @@ SurfaceBuffer *Surface::createSurfaceBuffer(struct wl_buffer *buffer)
bool Surface::postBuffer() {
#ifdef QT_COMPOSITOR_WAYLAND_GL
if (m_waylandSurface->handle() == m_compositor->directRenderSurface()) {
- SurfaceBuffer *surfaceBuffer = m_backBuffer? m_backBuffer : m_frontBuffer;
- if (surfaceBuffer && m_compositor->pageFlipper()) {
- if (m_compositor->pageFlipper()->displayBuffer(surfaceBuffer)) {
- surfaceBuffer->setPageFlipperHasBuffer(true);
- m_compositor->setDirectRenderingActive(true);
- return true;
- } else {
- qDebug() << "could not post buffer";
+ SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer();
+ if (surfaceBuffer && surfaceBuffer->waylandBufferHandle()) {
+ if (m_compositor->pageFlipper()) {
+ if (m_compositor->pageFlipper()->displayBuffer(surfaceBuffer)) {
+ surfaceBuffer->setPageFlipperHasBuffer(true);
+ m_compositor->setDirectRenderingActive(true);
+ return true;
+ } else {
+ qDebug() << "could not post buffer";
+ }
}
}
}
diff --git a/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp
index ced3ed2f0..61e241c32 100644
--- a/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp
+++ b/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp
@@ -199,6 +199,9 @@ void SurfaceBuffer::handleDisplayed()
void *SurfaceBuffer::handle() const
{
+ if (!m_buffer)
+ return 0;
+
if (!m_handle) {
SurfaceBuffer *that = const_cast<SurfaceBuffer *>(this);
if (isShmBuffer()) {