summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel van Vugt <daniel.van.vugt@canonical.com>2015-08-12 11:35:49 +0000
committerCI Train Bot <ci-train-bot@canonical.com>2015-08-12 11:35:49 +0000
commite6375102adf246e1d604b6b5749867127e52203b (patch)
treebe24399c13f98de8f2bdf424aaf9c1b05303c660
parent3b8c279a3e3e8977a608b119efee544d7ee6d63c (diff)
parent43443ddd7ebe4417fd2b033b7aea27de298f27db (diff)
MirSurfaceItem: Remove an unnecessary and potentially infinite loop
(LP: #1477430) We only need to "drop" or consume one frame to do the job of waking the client up. Fixes: #1477430 Approved by: Gerry Boland, PS Jenkins bot
-rw-r--r--src/modules/Unity/Application/mirsurfaceitem.cpp11
-rw-r--r--src/modules/Unity/Application/mirsurfaceitem.h2
2 files changed, 7 insertions, 6 deletions
diff --git a/src/modules/Unity/Application/mirsurfaceitem.cpp b/src/modules/Unity/Application/mirsurfaceitem.cpp
index 53331e4..e8f1f2b 100644
--- a/src/modules/Unity/Application/mirsurfaceitem.cpp
+++ b/src/modules/Unity/Application/mirsurfaceitem.cpp
@@ -233,7 +233,7 @@ MirSurfaceItem::MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
connect(&m_frameDropperTimer, &QTimer::timeout,
- this, &MirSurfaceItem::dropPendingBuffers);
+ this, &MirSurfaceItem::dropPendingBuffer);
// Rationale behind the frame dropper and its interval value:
//
// We want to give ample room for Qt scene graph to have a chance to fetch and render
@@ -735,22 +735,23 @@ void MirSurfaceItem::updateMirSurfaceFocus(bool focused)
}
}
-void MirSurfaceItem::dropPendingBuffers()
+void MirSurfaceItem::dropPendingBuffer()
{
QMutexLocker locker(&m_mutex);
const void* const userId = (void*)123; // TODO: Multimonitor support
- while (m_surface->buffers_ready_for_compositor(userId) > 0) {
+ int framesPending = m_surface->buffers_ready_for_compositor(userId);
+ if (framesPending > 0) {
// The line below looks like an innocent, effect-less, getter. But as this
// method returns a unique_pointer, not holding its reference causes the
// buffer to be destroyed/released straight away.
for (auto const & item : m_surface->generate_renderables(userId))
item->buffer();
- qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::dropPendingBuffers()"
+ qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::dropPendingBuffer()"
<< "surface =" << this
<< "buffer dropped."
- << m_surface->buffers_ready_for_compositor(userId)
+ << framesPending-1
<< "left.";
}
}
diff --git a/src/modules/Unity/Application/mirsurfaceitem.h b/src/modules/Unity/Application/mirsurfaceitem.h
index 952d3cd..24fb5ae 100644
--- a/src/modules/Unity/Application/mirsurfaceitem.h
+++ b/src/modules/Unity/Application/mirsurfaceitem.h
@@ -105,7 +105,7 @@ protected:
private Q_SLOTS:
void surfaceDamaged();
- void dropPendingBuffers();
+ void dropPendingBuffer();
void scheduleTextureUpdate();
void scheduleMirSurfaceSizeUpdate();